![]() |
Eye of the Nile Docs
Everything you need to know to get started!
|
Basic projectile functionality that every other projectile type must inherit from to be compatible with other systems (like the attack manager). You can also put this script onto any object or prefab to give it normal projectile functionality.
Documentation updated 11/13/2024
Public Member Functions | |
void | FlipDirection () |
Protected Member Functions | |||
virtual void | AwakeMethods () | ||
Runs when Awake() is called. | |||
virtual void | StartMethods () | ||
Plays the spawn sound effect. | |||
virtual void | OnTriggerEnterMethods (Collider2D collision) | ||
Runs if the projectile collides with an object (and it's a trigger zone). Does nothing by default. | |||
virtual void | OnCollisionEnterMethods (Collision2D collisionInfo) | ||
Runs if the projectile collides with an object. Damages the object it collided with if possible, then destroys the projectile.
| |||
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. | |||
Protected Attributes | |
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.". | |
Properties | |
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 Member Functions | |
void | Awake () |
Updates the direction the projectile is facing and runs AwakeMethods(), which can be changed in scripts that inherit from BaseProjectile. | |
void | Start () |
Runs StartMethods(), which can be changed in scripts that inherit from BaseProjectile. | |
void | OnTriggerEnter2D (Collider2D collision) |
Runs OnTriggerEnterMethods(), which can be changed in scripts that inherit from BaseProjectile. This is required if your projectile's Collider2D component is set to be a trigger. | |
void | OnCollisionEnter2D (Collision2D collisionInfo) |
Runs OnCollisionEnterMethods(), which can be changed in scripts that inherit from BaseProjectile. Afterwards, destroys the projectile, if enabled. | |
|
private |
Updates the direction the projectile is facing and runs AwakeMethods(), which can be changed in scripts that inherit from BaseProjectile.
|
protectedvirtual |
Runs when Awake() is called.
Currently does nothing and exists so inheriting functions can use it.
Reimplemented in BoneProjectile, and BoulderProjectile.
void BaseProjectile.FlipDirection | ( | ) |
Flip the direction the projectile is facing (and thus moving). Switches facingLeft to be the opposite of what it currently is.
|
private |
Runs OnCollisionEnterMethods(), which can be changed in scripts that inherit from BaseProjectile. Afterwards, destroys the projectile, if enabled.
collisionInfo | Represents the object the projectile collided with. |
|
protectedvirtual |
Runs if the projectile collides with an object. Damages the object it collided with if possible, then destroys the projectile.
collisionInfo | Represents the object the projectile collided with. |
Steps: If the object we collided with has an ObjectHealth AND at least one of the following is true:
Reimplemented in BoneProjectile, BoulderProjectile, and EarthquakeProjectile.
|
private |
Runs OnTriggerEnterMethods(), which can be changed in scripts that inherit from BaseProjectile. This is required if your projectile's Collider2D component is set to be a trigger.
collision | Represents the object the projectile collided with. |
|
protectedvirtual |
Runs if the projectile collides with an object (and it's a trigger zone). Does nothing by default.
collision | Represents the object the projectile collided with. |
Reimplemented in BoneProjectile.
|
private |
Runs StartMethods(), which can be changed in scripts that inherit from BaseProjectile.
|
protectedvirtual |
Plays the spawn sound effect.
Reimplemented in BoneProjectile, BoulderProjectile, and TornadoProjectile.
|
protected |
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.
|
protected |
The amount of damage the projectile will apply if it comes in contact with something it can damage.
|
protected |
If true, the projectile can damage objects that aren't the player (assuming they have an ObjectHealth component).
|
protected |
If true, the projectile can damage the player.
|
protected |
If true, the projectile will destroy itself when it hits something (regardless of if it can damage it or now).
|
protected |
When facingLeft is true, the sprite will be flipped. Usually used to make the sprite "face the way the projectile is moving.".
|
protected |
Sound effect that plays when the projectile is spawned in.
|
protected |
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.
|
getprivate set |
True if the projectile is facing (and thus moving) to the left. Likewise, false if the projectile is facing to the right.
|
getprivate 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.