Script for a boulder that rolls until its hitbox tells it to break. BoulderHitbox is responsible for detecting collisions and dealing damage.
Documentation updated 8/26/2024
- Author
- Roy Pascual
|
void | BreakBoulder () |
| Triggered by the boulder hitbox when it hits an object on the collisionLayers, or the boulder is set to despawn. Gets the object's collider, instantiates boulder particles, and destroys the boulder.
|
|
|
Transform | boulderParticles |
| Particles the boulder will spawn when it breaks.
|
|
int | damage = 30 |
| Amount of damage the boulder will apply if it hits an object on one of the collisionLayers.
|
|
LayerMask | collisionLayers |
| Objects on these layers will be damaged by the boulder. Set in the Unity Editor.
|
|
|
void | Awake () |
| Set reference to rigidbody.
|
|
void | Start () |
| Apply initialForce to the boulder.
|
|
|
Rigidbody2D | boulderBody |
| Reference to the rigidbody of the boulder.
|
|
float | initialForce = 100f |
| Force that is applied when the boulder is first spawned in.
|
|
◆ Awake()
void BoulderHazard.Awake |
( |
| ) |
|
|
private |
Set reference to rigidbody.
◆ BreakBoulder()
void BoulderHazard.BreakBoulder |
( |
| ) |
|
Triggered by the boulder hitbox when it hits an object on the collisionLayers, or the boulder is set to despawn. Gets the object's collider, instantiates boulder particles, and destroys the boulder.
◆ Start()
void BoulderHazard.Start |
( |
| ) |
|
|
private |
Apply initialForce to the boulder.
◆ boulderBody
Rigidbody2D BoulderHazard.boulderBody |
|
private |
Reference to the rigidbody of the boulder.
◆ boulderParticles
Transform BoulderHazard.boulderParticles |
Particles the boulder will spawn when it breaks.
◆ collisionLayers
LayerMask BoulderHazard.collisionLayers |
Objects on these layers will be damaged by the boulder. Set in the Unity Editor.
- Note
- To set the layer an object is on, go to the top right of the inspector tab and click the "Layers" drop down menu. Check the ones you want applied to that object. Then, you can come back to the boulder prefab and add that layer to the collision layers.
◆ damage
int BoulderHazard.damage = 30 |
Amount of damage the boulder will apply if it hits an object on one of the collisionLayers.
◆ initialForce
float BoulderHazard.initialForce = 100f |
|
private |
Force that is applied when the boulder is first spawned in.
The documentation for this class was generated from the following file: