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

Detailed Description

Script for a boulder that the player can throw as a projectile. Adapted from BoulderHazard. Inherits from BasicProjectile.

Documentation updated 9/7/2024

Author
Stephen Nuttall

Public Member Functions

void BreakBoulder ()
 Breaks the boulder by spawning particles and destroying this object.
 
- Public Member Functions inherited from BaseProjectile
void FlipDirection ()
 

Protected Member Functions

override void AwakeMethods ()
 Get reference to the boulder's rigidbody.
 
override void StartMethods ()
 Apply initial force based on the direction the boulder is facing.
 
override void OnCollisionEnterMethods (Collision2D collisionInfo)
 Empty. The collision is handled by the boulder's hithox, so we want the functionality of the base OnCollisionEnterMethods() to be ignored.
 
- Protected Member Functions inherited from BaseProjectile
virtual void OnTriggerEnterMethods (Collider2D collision)
 Runs if the projectile collides with an object (and it's a trigger zone). Does nothing by default.
 
void UpdateFacing ()
 Flips the sprite and movement direction (if a compatable component for projectile movement is attached) depending on if the projectile is currently facing left or right.
 

Properties

LayerMask collisionLayers [get, private set]
 Objects on these layers will break the boulder and possibly get damaged if the boulder collides with them.
 
- Properties inherited from BaseProjectile
int refDamage [get, private set]
 A mirror of damage that allows for other objects to read its value without changing it, and also allowing damage to appear in the Unity Editor.
 
bool facingLeft = false [get, private set]
 True if the projectile is facing (and thus moving) to the left. Likewise, false if the projectile is facing to the right.
 

Private Attributes

Rigidbody2D boulderBody
 Reference to the boulder's rigidbody.
 
Transform boulderParticles
 Reference to the particles to spawn when the boulder breaks.
 
float initialForce = 100f
 Initial force applied to the boulder when spawned in.
 

Additional Inherited Members

- Protected Attributes inherited from BaseProjectile
GameObject sprite
 Reference to the game object that holds the sprite renderer of the projectile. Often this is just the projectile itself, but sometimes there's a child with the sprite. This allows compatability with both systems.
 
int damage = 30
 The amount of damage the projectile will apply if it comes in contact with something it can damage.
 
bool damagePlayers = true
 If true, the projectile can damage the player.
 
bool damageNonPlayers = true
 If true, the projectile can damage objects that aren't the player (assuming they have an ObjectHealth component).
 
bool destroyOnImpact = true
 If true, the projectile will destroy itself when it hits something (regardless of if it can damage it or now).
 
EventReference spawnSFX
 Sound effect that plays when the projectile is spawned in.
 
bool flipSprite = true
 When facingLeft is true, the sprite will be flipped. Usually used to make the sprite "face the way the projectile is moving.".
 

Member Function Documentation

◆ AwakeMethods()

override void BoulderProjectile.AwakeMethods ( )
protectedvirtual

Get reference to the boulder's rigidbody.

Reimplemented from BaseProjectile.

◆ BreakBoulder()

void BoulderProjectile.BreakBoulder ( )

Breaks the boulder by spawning particles and destroying this object.

◆ OnCollisionEnterMethods()

override void BoulderProjectile.OnCollisionEnterMethods ( Collision2D collisionInfo)
protectedvirtual

Empty. The collision is handled by the boulder's hithox, so we want the functionality of the base OnCollisionEnterMethods() to be ignored.

Reimplemented from BaseProjectile.

◆ StartMethods()

override void BoulderProjectile.StartMethods ( )
protectedvirtual

Apply initial force based on the direction the boulder is facing.

Reimplemented from BaseProjectile.

Member Data Documentation

◆ boulderBody

Rigidbody2D BoulderProjectile.boulderBody
private

Reference to the boulder's rigidbody.

◆ boulderParticles

Transform BoulderProjectile.boulderParticles
private

Reference to the particles to spawn when the boulder breaks.

◆ initialForce

float BoulderProjectile.initialForce = 100f
private

Initial force applied to the boulder when spawned in.

Property Documentation

◆ collisionLayers

LayerMask BoulderProjectile.collisionLayers
getprivate set

Objects on these layers will break the boulder and possibly get damaged if the boulder collides with them.


The documentation for this class was generated from the following file: