How to make the NPC Character/boss walk?

How do I…

make npc walk randomly?

What is the expected result

It should be running as normal, they randomly walk and if its on edge, they walk away from edge.

What is the actual result

NPC start walking confusedly, NPC stopped

Related screenshots

The problem is the wait actions. Say it’s 0. The code adds a wait but then it does the other events and in the next frame it starts again. The value is still 0 so it adds another wait. This buildup lasts for 3 seconds until the value of the variable is changed. As the wait actions time expire the rest of the event gets triggered for all of the builtup "wait* actions. And since the wait actions were triggered on different frames they’ll expire across different frames. The variable gets changed and this repeats for the other events. In some cases it’s also adding force in each frame.

If you want the object to change direction every 3 seconds then I would use a timer. Start the timer at the begining. When the time ≥ 3 seconds then stop the object, picks a number, changes the direction based on that number and restart the timer. Since you need to stop the object for all 3 options, you wouldn’t need to check for 0 bc it’s already stopped.

You might want to use a higher force. I left it at 5.

i get it, but my NPC keep floating, so i decided to make it simulate control, but the walking is not working, what should i do?

Can you post a pic of the events?

How are you setting the value of Ewalk and are there any conditions stoping the lines you posted from always being triggered? What are they subevents of.

there is no subevent, there is no conditions, i used randominrange

Are you using a timer? What exactly is happening?

so the timer is running normally, but the movement is freezed, cannot move except my movement when i turn off disable default control

The events that you posted are indented meaning they are subevents of something. Is it an event or an event group/comment.

Your code looks good. Either the conditions aren’t being checked/triggered on each frame or the variable isn’t being changed to a matching number.

the first event i make is walk first, so there is no subevents

your mistake has confused me a while, you shouldnt have put the event inside the event, thanks anyway

now how to make jump?

Are you starting the timer? It needs an initial start otherwise the time with never be greater or equal to 4. The events you posted won’t trigger unless either the timer is already running or Ejump is between 1 to 3.

i forgor to use timer at the start :skull: btw thanks

1 Like