Move NPC on Timer?

Hello Devs, Noob here.

I need help moving a npc in random direction at intervals. so after 5 seconds… npc walks 400 px then stops and waits for another interval.

Do I use an object timer to move the npc and scene timer for the pause?

I tried to add a topdown behaviour with disabled default, but this doesn’t work.

Thanks

IF you are going to have it always for 5 secs

Use condition called Compare Two Numbers
In 1st value type mod(TimeFromStart,5)
For sign of the test choose greater than
In 2nd value type 0
Trigger once

Thanks @ZeroX4

I just know I’ve screwed it up.

fixed it

Now I just need the movement. Thanks @ZeroX4

me personally, when i want npcs to wander around, i make an object variable called “want” or something like that, add the platformer character movement (or any character movement) and start an object timer at the beginning of the scene.
like this:
At the beginning of the scene: Start or reset timer “movement” of (NPC).

If timer “movement” of NPC is greater or than “RandomFloatInRange(3.5, 9.6)”: Change object variable “want” of (NPC) to “RandomInRange(1, 5)”, and Start or reset timer “movement” of NPC

If object variable “want” of (NPC) = 1: Simulate Left Key Press
(and it goes on…)

One thing I’d also recommend is having an object variable called “ID” for each instance, and put these events under it, so it’s a lot easier to manage

1 Like