I am going to break up this into a few more parts so that we can understand what I am doing to create this game.
First, we are going to look into our sprite's power-up folder and select the speed boost sprite. Take the first power-up sprite and put it into the hierarchy. Then size it by using X and Y settings and match them to the X and Y settings to the player. I used 0.5 and 0.5.
Then you will need to go and change the settings from background to foreground in the Inspector window. This will allow the background to set behind the sprite and not let it get lost in the background. Don’t forget to change the name of it to Speed Boost.
Next, you will need to look into the Inspector window and go to the Add Component. Then you will go and find 2D Box Collider. Once added you will click on the “Is Triggered” box. This will allow for it to collide with your player.
Then you will go to the Add Component button again, and find a 2D Rigid Body. Once added, go to the 2D Rigid Body in the Inspector window and find the Gravity. Change it to 0 so that it will fall easily.
In the next step, we could do two things. First, we could create another script for the Speed Boost or we could use another existing script. Why should we not write a separate script? This could tax the memory and allow interference to the game’s processor. Now our second option, we are going to use the Power-Up script, this will allow us to do some of what is already being used.
When you have done adding 2D Box Collider, 2D Rigid Body, and PowerUp script drag it to the Prefabs folder. Then delete the other from the Hierarchy.
This end of Part 1. Please like, comment, or send me a message or email. Ordain_angel@icloud.com. And as always ‘Thank you for reading!”