how to make something move randomly?
Dar
Member Posts: 37
Hello,
In my game I want it so when my shark touches the fish,i want the fish to move away to a new random position and then the shark goes there it moves away to somewhere else...
how can I do this?
Thanks so much! :c )
In my game I want it so when my shark touches the fish,i want the fish to move away to a new random position and then the shark goes there it moves away to somewhere else...
how can I do this?
Thanks so much! :c )
Comments
Create a rule inside the fish actor:
When actor overlaps or collides with actor shark
--interpolate self.position.x to random(40, 440)
duration .5
--interpolate self.position.y to random(40, 280)
duration .5
Interpolate will change any attribute from one thing to another and will take however long you specify to change. It is an AMAZING tool!
The random function will pick a random number between the 2 numbers you specify, in this case, 40 and 280. You have to use the expression editor in order for the random function to work! Just click the little "e" next to the text box and select random, then fill in the 2 numbers!
Hope this helps!
-Kyle
Rule(on the fish): When actor overlaps or collides with actor of type shark
Move to: X:randon(0,480) Y:random(0,320) relative to: scene
speed:???
thanks so much!
Great tool to use!
What's the best use for interpolate, why should you use it / not use it (if you want to create games for iPhone, also the 2G/3G)?