top of page
Search
  • Writer's pictureKieran Boyce

Collectables

Updated: Mar 28, 2020

Following on from the avatar I made before the next task is to make some power ups which last a limited amount of time. To start this I created a cube shrunk it down a bit and rotated it on an angle. Then I added a script to it that caused it to rotate making it look a bit more appealing to players. This was pretty simple and could be done in one line of code as all i was doing was constantly updating the rotate transform.



After this, I got the box collider on this box and changed it into a trigger meaning that the player will be able to overlap it instead of just walking into it.



I next went into the character controller component and created 2 more booleans one for double jump and one for speed boost as they are the 2 types of power ups I plan to make, both of these are default to false currently.


I also add in a new integer called jumps this checks how many times the player has jumped for the double jump. I then duplicate the jump code i already have and drop it outside the is grounded statement so that it will activate when the player is in the air. Then check if jumps are less than 1 as well as if the jump button is pressed and then incrementing the jumps int. I also set it back to zero when the player lands.



Next is to create another function called on trigger enter. this will be called when the player overlaps another trigger. Now to check which power up does what i created new tags for them so then i can do and if statement to check if that is the correct tag and if it is then to destroy the pickup and play a particle effect.


Now to make this timed I found that I could create an IEnumerator and use a function called WaitForSeconds where it can create a delay on how long before doing something so i set a delay on how long till the power up deactivates.



With this in the statement where I’m destroying my pickups i can use another function called StartCoroutine and then slot my IEnumerator in there.



For the speed boost I essentially just temporarily multiplied the speed by 5 and after 15 seconds have it revert back to the default.


The features itself in the end worked just fine most of the time I did run into a bug where the player would be able to triple jump after activating the powerup I struggled to find the cause for it though as I couldn't replicate it more than twice.

The power up items themselves worked just fine and disappeared when the player collected them and the powers were always activated so no problems there, the particle effects played as well each time which was good.


If anything, this feature lacks a bit of polish especially in the department for the effects as the collectibles themselves don’t have an effect so that the player can tell the difference between each one. as well as this the speed powerup is too fast I think and could do with some adjusting as the player suddenly going 5 times the speed so suddenly could cause some issues while playing. The effects which appeared on the player when a powerup was active could have looked a bit better as well as they were basic effects and by looking at them you wouldn’t really know what they are doing.





3 views0 comments

Recent Posts

See All

Comments


bottom of page