Day 19: RayCast, Reloaded

Austin Bryant
2 min readDec 22, 2020

--

I did not meet my own expectations on today’s agenda. I did come close however.

I managed to get everything but the last 2 segments complete today before I had to wrap up today’s work.

The first thing on my list today was to create a behavior for the enemy that let it know when a pick up was in front of the enemy and shoot at it.

My first thought to do this was just to create another Ray Cast that pointed downward. I mimicked my previous RayCast with just changing one part of the syntax to point it downward. For some reason it was not working at first. I spent some time carefully going through each part of the syntax to ensure that I was correct.

After, a little while longer than expected, I was able to get the enemies to behave correctly and they shot at any pickup below itself and destroyed the pickup.

Next on my list was to give the player the ability to get any powerup on the board to move toward the player by pressing down the “C” key. This ability took some time to implement.

At first I was trying to get the player to “see” the PowerUPS. This did not work because the PowerUPS randomly spawn and the ability is constant. So the player script did not like trying to find an object that was not there in the beginning.

Next, I moved the ability into the PowerUPS script, so when the PowerUPS is spawned it looks for the player instead and then when the player presses “C” on the keyboard the PowerUP moves toward the player. This worked very nicely.

Finally I was able to complete another RayCast that tells the enemy to try and avoid a player laser being thrown at it.

I started the final segment before the “Boss” enemy. This last segment is to create a “homing” projectile that moves toward any enemy close to it then destroys that enemy. I just have some code to write and finish up testing and I should be able to start my “Boss” tomorrow.

--

--