Projectile Logic


The projectile logic is very simple, and is completely contained within the PlayerProjectile script. All that was required for this was collision registry logic. The projectile constantly checks for collisions, and when it does collide with something, it gathers information on what it hit to decide how to act. When a projectile collides with anything, I wanted it to stop moving and to "stick into" whatever it hit. This meant freezing the projectiles rotation and enabling isKinematic. If the target hit is part of the environment, the projectile disappears after a few seconds and the logic reaches completion. If the target hit is an enemy, then the projectile becomes a child of the enemy. This is so the projectile sticks into the enemy and moves with them. The projectile stays in this state until the enemy dies. I chose to do this in favour of giving enemies health bars, so that the player could have some gauge of how damaged an enemy is. After a collision is detected with an enemy and this all happens, damage is dealt to the enemies health equal to a float called playerDamage. This is to allow for scalability with potential upgrades in the future. If the enemy dies, all projectiles are deleted along with the enemy due to being children.


-Griffin

Get Sanguine Falls

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.