Shield for the assault rifle class

 Author: Pedro Polanco III

    I was implementing the assault enemy and wanted to give him a shield but when applying the shield, I had issues determining whether a bullet is hitting the enemy from the front or the back. This would be a problem because the player would always be hitting the shield even if they are not supposed to be.

    The Way I went about fixing this was by using dot product math. I grabbed a vector between the enemy and bullet and then used the dot product with that vector and the enemy forward vector which allowed me to setup a "cone of vision" for the enemy. I then check to see if the dot product is positive or negative. Positive means I am in front of the enemy, negative means I am behind them and using this it allowed me to properly decrement from the shields or health. This will make it so that way the player has to destroy the shields if they attack from the front.

    

Comments

Popular posts from this blog

Adding assets to every enemy -- Owen Meyers

Sphere to AABB collision