Add VFX to your game
Tutorial
·
foundational
·
+10XP
·
60 mins
·
(15)
Unity Technologies

Particle effects simulate small objects like smoke, fire, and dust. These effects enhance visuals by adding depth, realism, and movement to scenes, which enriches the gameplay experience.
In this tutorial, you will create visual effects to simulate an explosion when the enemy catches the player and a pickup effect for the tokens.
Languages available:
1. Overview
Particle effects simulate small objects like smoke, fire, and dust. These effects enhance visuals by adding depth, realism, and movement to scenes, which enriches the gameplay experience.
In this tutorial, you will create visual effects to simulate an explosion when the enemy catches the player and a pickup effect for the tokens.
By the end, your game should look something like this:
2. Requirements
In order to successfully complete this challenge, your project must include the following elements, styled according to the theme outlined in your design document:
- An explosion effect that spawns when the enemy catches the player.
- An effect that spawns when the player picks up a token
3. Review your design document
Your Game Design Document (GDD) is still a work in progress. Take a moment to open your GDD now and review it.
Think about your specific theme and the type of effects that would make sense for your game.
4. Review the asset pack
Take some time to review the assets provided in the UCU Game Developer package that you downloaded and imported earlier in the Fill out a Game Design Document tutorial.
If you did not download and import those assets, you can do that now.
In the asset pack, you can browse the Prefabs > VFX folder, which contains a few sample particle systems to get you started. Drag these into your scene to preview them.
5. Challenge guidance
The following sections will provide you with some guidance on each of the tasks in this challenge.
Explosion on collision
- The explosion effect can be instantiated using the enemy collision function in your PlayerController script. You can add this line of code to your OnCollisionEnter function in the PlayerController script to instantiate the effect.
Remember you will have to set a public GameObject variable named explosionFX and drag the effect to the relevant slot before you test the game.
- You will notice we use quaternions to describe the rotation of the instantiated particle system. Quaternions are a special way to describe rotations and orientations in 3D space that are different from the standard euler angles we usually use. In some specific cases in games euler angles may cause a problem called gimbal lock, whereas quaternions solve this problem.
- Remember to set the particle system to play on awake.
- If you need a reminder on how to do this, review the VFX mission in the Creative Core pathway on Unity Learn.
Pickup effect
- The pickup effect can be instantiated using the OnTriggerEnter function in your PlayerController script by adding this line of code to your OnTriggerEnter function
It is best practice to remove the effects as well when they are done playing. This line of code can be added to your OnTriggerEnter function right after the previous line to destroy the VFX again.
The particle system will play it’s full lifetime length before disappearing from the screen
- Remember to set the Particle Simulation space to Local to make it stay in the location of the pickup.
6. More things to try
If you want to develop your skills further, explore new concepts, or improve your project, check out some of the optional activities below. Each activity is identified as being either Easy, Medium, or Difficult, so you know what level of difficulty to expect.
These activities are entirely optional, so if you’re not interested, no problem – just skip this step. We do recommend attempting at least one of them in order to get the most out of this learning experience. Good luck!
Easy: Win celebration
To enhance the gaming experience when the player wins, incorporate a jubilant celebration effect triggered by the existing win activation function in the PlayerController script.
Medium: Add trailing smoke or dust behind the ball as it moves
You can enhance the sense of speed of the rolling ball by adding trailing smoke or dust behind it. Ensure that the effect only activates when the ball is in motion, which will provide a realistic touch. Keep in mind the effect should dynamically adjust based on the direction of the ball's movement, for a more natural and polished outcome.
7. Next steps
In this tutorial, you created visual effects to add to the visual impact of the game and create a more immersive experience. In the next tutorial, you will learn how to add user interface elements to the game.