Road TO Dev — Let’s power UP!

Rob Smith
3 min readApr 14, 2021

--

Ok so now we have our basic mechanics down let’s add a little extra fun to the game with powerups. There are many ways to implement these I will start with a simple method right now and then later when we get more powerups we’ll discuss a different way to handle them.

In order for the powerup to work we need to handle a couple of things. First and foremost we need to decide what we want to have done. I am going with adding a triple shot to our players attack. To start we need to add an object to represent the powerup. I already have a nice image for mine but you can do whatever you want. We will need to get the object ready so don’t forget to name it, resize it to fit your scene if it doesn’t already, and setup a collider on it for what we will need.

Now we need to create a script to tell our newly created powerup what to do when it’s created and to let the player know when it’s hit. Knowing we will have multiple powerups it’s best to create one script to control them all so we are doing just that. So for starters we want to have our object move down the screen so the player can collect it. As with our player we want to create a speed variable to use here. But because we know we just want it to move down we can use a built in Vector3.down which is just a shorthand way of writing Vector3(0, -1 , 0).

make sure to add the script to the prefab and now we can see if it moves and see if we like our speed. I set mine to 5 here.

Now keep in mind the game doesn’t know this powerup was missed and is offscreen so don’t forget to put a check in the script. We can even create a method for this to help keep our code cleaner.

--

--

Rob Smith
Rob Smith

Written by Rob Smith

Hi there! I am currently on the path to learn how to become a unity developer and will be documenting my journey as best as I can here. Thanks for looking!

No responses yet