extends Control
var mortar = preload("res://Scenes/Mortar.tscn") # error on this line
var player
var rand1
var rand2
var randtim
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
$AttackTimer.start()
player = get_tree().get_first_node_in_group("player")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
rand1 = randi_range(2,-2)
rand2 = randi_range(2,-2)
self.position.x += rand1
self.position.y += rand2
func _on_attack_timer_timeout() -> void:
if not Enemiesdisabled.enemiesdisabled:
randtim = randf_range(2,4)
$AttackTimer.wait_time = randtim
var m = mortar.instantiate()
if player.speed > 0:
m.global_position.x = player.global_position.x + 1600
elif player.speed < 0:
m.global_position.x = player.global_position.x + 1600
else:
m.global_position.x = player.global_position.x
$AttackTimer.start()
m.global_position.y = player.global_position.y
get_parent().get_parent().add_child(m)
$AnimationPlayer.play("shoot")
await get_tree().create_timer(0.3).timeout
var m1 = mortar.instantiate()
if player.speed > 0:
m1.global_position.x = player.global_position.x + 1600
elif player.speed < 0:
m1.global_position.x = player.global_position.x + 1600
else:
m1.global_position.x = player.global_position.x
if player.in_air:
m1.global_position.y = player.global_position.y
get_parent().get_parent().add_child(m1)
$AnimationPlayer.play("shoot")
it says that it doesnt preload even tho the path is correct