Creating a Negative Pickup — Make Player Move in a Random Direction
Affection player movement
Objective: create a new collectable that makes the player move in a random direction.
First we have to create the collectable by dropping the sprite in the scene and changing the size and the color.
Then I added the collider, rigidbody and the powerup script to give the powerup (and assigned a powerup ID) behavior to this object.
For this collectible I created an animation then I selected the Animation window and changed the color over the time.
At this point I had the look that I wanted for the negative pickup.
Next in the player script I created a variable called “_isSystemHacked” to enable and disable the movement. Also I declared a variable called “_hackingPath” to calculate the random direction. Then I create a coroutine to calculate the random path and enable the movement for 10 sec and a public function to start the coroutine.
In the powerup script I called the function to activate the random movement in the new case.
Finally in the inspector I added the negative pickup to the powerup array in the spawn manager.
That’s it!!! New negative pickup to make the game a little bit harder.