Gamespace: PickUp Collectable Items

I created a way for my items (mini balls) to be picked up by my player.
I also added a particle system so that when the balls were picked up, they almost 'exploded' making the Gamespace more interesting.



My particle system before changing the values


My particle system after changing the values

This was the first 'PickUp' script that was used so that the player could collect the items.
The ParticleSystem named 'particles', the Renderer named 'collectableItem' and the Vector3 named 'ball' were all made public so that they could be edited in the inspector.

The function 'OnTriggerEnter' was used so that if something (the player) collided with the item, this function is triggered.
The if statement states that if an object has the tag 'Player' and has collided with the item, the particle system will play (Particles.Play()), the components collider has been disenabled so that it cannot be picked up again, the gameObject is destroyed when the particle system is played and the item is hidden (the item is disenabled).


PickUp script

This is the inspector for the gameObject 'collectableItem' all items (mini balls) where child GameObjects under this parent gameObject.


Collectable Item Inspector

This was one of the items that the player could collect.
The PickUp script was attached to each item.
A capsule collider was also added to each item so that the ball could collide with the item and activate the 'OnTriggerEnter' function in the PickUp script. The height was set to two in the direction of the Y-axis so that the balls were able to be collected easily.


Item Inspector

This gameObject was also a child of each item which included the particle system allowing particles to explode around the object when it had been picked up. 

The looping was switched off so that the particle system could only be activated when it was triggered by the 'OnTriggerEnter' function in the PickUp script.

Values such as the duration, speed, size, lifetime etc. were changed.


Particle system

The emission was changed so that the particles emitted one burst when the item was picked up.
The shape was also edited and the radius of the shape including the scale.


Particle system - Emission & shape

The renderer option was edited so that a material was added (given the particles colour).


Particle system - Renderer

Comments

Popular posts from this blog

Unity Project 4: Ball platformer game

[Research] Traditional Poster Design (4CTA1214)