An enemy that moves at regular intervals

I’ve been thinking about this a lot…
Really a lot
I tried many things with the help of many people, but my “enemy” didn’t move yet…
What’s the problem
Of course it’s my brain!
So I need your help
Please help me…
You are my last hope

Wha I want
the action of an enemy moving at constant coordinates every time (ex. 3 seconds)

What I made
Never moving enemy and this code

add a physics_process method so your movement-code actually gets executed:

func _physics_process(delta: float) -> void:
    enemy_movement_control(delta)

and dont forget to start your timer again after the timeout or after it reaches it position
And just a side note: you dont need to do this:

@onready var enemy_object = $"."

func enemy_movement_control(delta : float):
    enemy_object.global_position = ...

# it automatically uses the current object if you dont give a specific object:
func enemy_movement_control(delta : float):
    global_position = ...

1 Like

Thank you for your help…!!!
But error message appeared…
'Invalid call. NOnexistent ‘Vector2’constructor.’

replace this:
var enemy_cooldinate_random_value
with this
var enemy_cooldinate_random_value = 9

and change this:

func enemy_movement_control(delta : float):
    enemy_object.global_position = ...

to this:

func enemy_movement_control(delta : float):
    enemy_object.position = ...
1 Like

???
It works perfectly!!!
I don’t know how much more I can thank you…
herrspaten, Thank you from the bottom of my heart…

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.