Share on facebook
Share on twitter
Share on google

These components define how the trap works: moving, rotating using physics or particles, and launching projectiles.

You can use multiple mechanisms in a single trap. Putting them together as parent-child will result in a more complex trap. 

Play Mode: After activation, the mechanism executes itself once only, or as a loop until the deactivation happens.

Cooldown: Seconds before the mechanism can reactivate.  0 means no cooldown.

Reset on Finish: This only available in Only Once play mode. 

Effects: A list of rules that controls effects. You can assign an Effect Handler to call a selected command on it when an event happens in the mechanism.

Instead of a keyframe animations, we are using procedural animations to control the traps. By changing the parameters, you can achieve totally different results.

Loop Settings

This section only available if you selected the Loop play mode. You can control how to use a loop in this mechanism.

  • Loop Mode: Repeat is the standard loop mode. In the case of Ping-Pong, the loop goes back and forth.
  • Duration: seconds to finish one loop.
  • Curve: you can customize the movement dynamic with this curve.
  • Different Reverse [only visible in Ping Pong mode]: Enabling this option allows you to set different duration and curve when the loop goes backward.

Animator Settings

With this component, you can move (Translate) or rotate your object.

Translate: the script moves the game object between the start position and the end position. This movement is relative to the anchor transform.

Rotate: the script rotates the game object by an angle over the duration.

This component shoots a projectile using object pooling. In short, it only instantiates a number of projectiles then reuse the already instantiated. This is good for performance. (more information here)

Force: the force that is applied to the projectile

Max Distance: projectile deactivates and returns to the pool after this distance even if it didn’t collide with anything.

Ammunition: you can limit how many times the launcher can shoot. 0 means unlimited ammo.

Stick on Collision: the projectile will stick to and move with the object it collides. It disappears when the object pooler reuses it.

Projectile

The script can handle multiple projectile prefabs.  As a default, it shoots one by one based on the order of the list. Enable the Randomize option for random selection.

Pool Size: the script will instantiate only this amount of projectile from each prefab.

This component moves the projectile. It’s inherited from a Damage Source, so you can set the damage.

This mechanism controls the particle you assign in the Particle property. 

This simple mechanism controls the rigidbody on the same GameObject. On activate, the script turns off the isKinematic property and allows the physics engine to apply gravity to this object.

  • Duration: how long the physic simulation should happen. 
  • Reset on Finish: This only available in Only Once play mode. After the simulation ended, the script resets the game object position and rotation. In loop mode, this is automatically happening after every sequence.