Script that powers BoneProjectile.prefab that Skeleton Guy.prefab uses.
Documentation updated 9/4/2024
- Author
- Roy Pascual
- Note
- Unlike most projectiles, this projectile's Collider2D component is set to be a trigger, so it uses OnTriggerEnterMethods(). However, OnCollisionEnterMethods() is also filled out with the same code. I'm not sure why that is but it doesn't seem necessary.
|
float | initialXForce = 25f |
| The horizontal force applied to the projectile upon spawning in.
|
|
float | initialYForce = 50f |
| The vertical force applied to the projectile upon spawning in.
|
|
|
override void | AwakeMethods () |
| Sets reference to rigidbody, and disables damage to non-players.
|
|
override void | StartMethods () |
| Apply initial force based on the direction the projectile is facing.
|
|
override void | OnTriggerEnterMethods (Collider2D collisionInfo) |
| Runs base.OnCollisionEnterMethods() but adapted to be compatable with OnTrigger (the parameter is slightly different).
|
|
override void | OnCollisionEnterMethods (Collision2D collisionInfo) |
| Same as base.OnCollisionEnterMethods(). Not necessary because the projectile's Collider2D is a trigger, so this function will never run. Additionally, since this function doesn't override any of the behavior of the base version, it wouldn't need to be listed anyway.
|
|
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.
|
|
|
void | Update () |
| Rotates the projectile.
|
|
|
Rigidbody2D | boneRb |
| Reference to the rigidbody of the projectile.
|
|
|
void | FlipDirection () |
|
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.".
|
|
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.
|
|
◆ AwakeMethods()
override void BoneProjectile.AwakeMethods |
( |
| ) |
|
|
protectedvirtual |
Sets reference to rigidbody, and disables damage to non-players.
Reimplemented from BaseProjectile.
◆ OnCollisionEnterMethods()
override void BoneProjectile.OnCollisionEnterMethods |
( |
Collision2D | collisionInfo | ) |
|
|
protectedvirtual |
Same as base.OnCollisionEnterMethods(). Not necessary because the projectile's Collider2D is a trigger, so this function will never run. Additionally, since this function doesn't override any of the behavior of the base version, it wouldn't need to be listed anyway.
- Todo
- Test if this function is secretly necessary. If not (likely), remove.
Reimplemented from BaseProjectile.
◆ OnTriggerEnterMethods()
override void BoneProjectile.OnTriggerEnterMethods |
( |
Collider2D | collisionInfo | ) |
|
|
protectedvirtual |
Runs base.OnCollisionEnterMethods() but adapted to be compatable with OnTrigger (the parameter is slightly different).
Reimplemented from BaseProjectile.
◆ StartMethods()
override void BoneProjectile.StartMethods |
( |
| ) |
|
|
protectedvirtual |
Apply initial force based on the direction the projectile is facing.
Reimplemented from BaseProjectile.
◆ Update()
void BoneProjectile.Update |
( |
| ) |
|
|
private |
◆ boneRb
Rigidbody2D BoneProjectile.boneRb |
|
private |
Reference to the rigidbody of the projectile.
◆ initialXForce
float BoneProjectile.initialXForce = 25f |
The horizontal force applied to the projectile upon spawning in.
◆ initialYForce
float BoneProjectile.initialYForce = 50f |
The vertical force applied to the projectile upon spawning in.
The documentation for this class was generated from the following file: