![]() |
Eye of the Nile Docs
Everything you need to know to get started!
|
Script for a boulder that the player can throw as a projectile. Adapted from BoulderHazard. Inherits from BasicProjectile.
Documentation updated 9/7/2024
Public Member Functions | |
void | BreakBoulder () |
Breaks the boulder by spawning particles and destroying this object. | |
![]() | |
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. | |
![]() | |
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. | |
![]() | |
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 | |
![]() | |
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.". | |
|
protectedvirtual |
Get reference to the boulder's rigidbody.
Reimplemented from BaseProjectile.
void BoulderProjectile.BreakBoulder | ( | ) |
Breaks the boulder by spawning particles and destroying this object.
|
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.
|
protectedvirtual |
Apply initial force based on the direction the boulder is facing.
Reimplemented from BaseProjectile.
|
private |
Reference to the boulder's rigidbody.
|
private |
Reference to the particles to spawn when the boulder breaks.
|
private |
Initial force applied to the boulder when spawned in.
|
getprivate set |
Objects on these layers will break the boulder and possibly get damaged if the boulder collides with them.