This is a very simple behavior for objects that you want to move randomly up, down, left, and right.
First, add objects to the scene.
Create an extension and name it whatever you like.
Add a behavior and name it whatever you like.
Add the properties "Speed" and "Timer." Speed will control the object's movement speed, while Timer will determine how often the object changes direction. Additionally, add an Animation property to change the object's animation.
Add an "onCreated" function. This function will execute these actions at the beginning of the object's life.
Add a "doStepPreEvents" function. Use the properties "Speed" and "Timer" that were set earlier in the behavior properties.
And finally, add the behavior to the object.
And there you have it! Now you have a very simple random 4-direction movement behavior!
Comments
Post a Comment