Grenades are Trajectory Objects that can destroy themselves after they collide with an object or a set amount of time. They are thrown by the ThrowableItem component and can explode in the character’s hand if they aren’t thrown fast enough.
A new grenade can be created by performing the following:
- Open the Object Manager and create a new object of type Grenade.
- A Capsule Collider will be added to the shell by the Object Manager. A Sphere Collider can also be used if the shell is more spherical.
- Adjust the Grenade values to match the type of grenade. In most cases only the Spawned Objects On Destruction value will need to be adjusted.
- Assign the prefab to the Throwable Item that should throw it. This is assigned to the Thrown Object field under the Throw foldout:
The layers that the object can stick to.
Destroy On Collision
Should the grenade be destroyed when it colliders with another object? Most grenades will have this option set to false.
The amount of time after a collision that the object should be destroyed.
Spawned Objects On Destruction
The objects which should spawn when the object is destroyed. Each element within this array has the following options:
- Object: the object that should be spawned
- Probability: the likelihood that the object will be spawned (0 – 1). A higher value means it is more likely to be spawned.
- Random Spin: should a random spin be applied to the object after it has spawned?
The length of time before the grenade destructs.
A reference to the pin that is removed before the character throws the object (can be null).