Phase 2: PowerUp Collection
Objective: When the “C” key is pressed by the Player the PowerUps move towards the player quickly.
The first thing I will need to do is create a reference to the Player. This will be used to get the position of the Player.
Next, I will create a Method that will get the position of the player and subtract it from the powerup position to create a new vector3 call _direction. Also, I will normalized the _direction to create a much smoother movement. the last thing to do is subtract _direction from the current position and move at three times the normal speed.
Now that we have the method complete we need to check for the “C” key and call the Method.
Let's see this in action