Game Project: Flying Game – Part 5 – Projectile and Environment Interaction (Part 2)

June 8, 2021

Flying Game

Projectile


Overview

I wanted to have the player projectile add force to objects that it came in contact with. This originally was just to prevent strange occurrences where originally if the player hit obstacles sitting on top of others, nothing would happen since the only force moving them at all was gravity. This additional force adds some extra displacement to make sure that whenever any objects are hit, there is some dramatic impact.

Voxelized Environment Obstacles Update

IDestructible Interface Update for Voxel Obstacle Element Class

This interface is implemented by the individual voxel obstacles. It originally just had a Destroyed() method, but with this update I wanted to add a secondary method to deal with simply being hit at all, so I added a Damaged() method. I then also renamed the Destroyed() method to EndLife() since it may not necessarily be destroyed when its job is done.

Internal Hit Cooldown Timer

Because the objects were receiving forces from various angles and running into other elements, sometimes objects could quickly be pushed slightly out of the projectile and then be hit again by the same projectile and receive another boost in force applied. To prevent this, I added an internal hit cooldown timer to the individual elements so that they would not react again until a certain time had passed. This will most likely be set to a relatively low time (i.e. <1s), but as can be seen in the test video a timer of about 10s is used just to check its validity.


Video: Sonic Boom Projectile and Obstacle Internal Timer

via Blogger http://stevelilleyschool.blogspot.com/2021/06/game-project-flying-game-part-5.html