EditMake an actor behave randomly
Basic Idea: Many times we want an action to be random. For example, a spaceship shooting down at a random interval. This can be done easily using the timer event. Define the shooting behavior triggered by a timer.
Sample Game:
http://www.popfly.com/users/team/HowDoI-RandomBehaviorDetails:
- Define a shooting action
- Trigger it on a timer
- Make that timer's interval random
Actor->Behavior->Shoot->Event
 Random Timer event (Click the image to view full size) |
Advacned Fun: You can use filters to introduce more complex game logic. Suppose you want spaceship to shoot randomly but only when it was fired upon. This is how you could do that:
- Add a property to Spaceship
- Add a property change event to the Spaceship
- Triggered by a random timer
- Changes ‘Shoot’ to 1
- Add another property change event to the Spaceship
- Triggered by a random timer
- Changes ‘Shoot’ to 0
- Add Shoot event to the Spaceshup
- Triggered on collision
- Filters on property ‘Shoot’ = 1