Eye of the Nile Docs
Everything you need to know to get started!
Loading...
Searching...
No Matches
BoulderHazard Class Reference

Detailed Description

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

Public Member Functions

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.
 

Public Attributes

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.
 

Private Member Functions

void Awake ()
 Set reference to rigidbody.
 
void Start ()
 Apply initialForce to the boulder.
 

Private Attributes

Rigidbody2D boulderBody
 Reference to the rigidbody of the boulder.
 
float initialForce = 100f
 Force that is applied when the boulder is first spawned in.
 

Member Function Documentation

◆ 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.

Member Data Documentation

◆ 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: