Adding Visual Effects using Scale

Make the Player feel like moving faster

Thruster VFX


To create this effect we will be change the scale of our thruster game object. This is a follow up to the previous article where we created a sprint function.

The function we will be using is:

In our game we got 2 states for speed increases. When the sprint is used and when the powerup speed boost is active. Important to keep in mind is they can be stacked. Sprint can be used while speed powerup is active.

Rescale Thruster with Code

Put the following code at the top of the script. These are the value to adjust the scale and the position during the speed increase.

//speed vfx config
private Vector3 _scaleChange = new Vector3(0.2f, 0.4f, 0);
private Vector3 _posChange = new Vector3(0, -0.25f, 0);
Thruster Sprint VFX

This code is the actual modifying of the scale and adjusting the position.

if (Input.GetButtonDown("Fire3"))
_speed *= _sprintModifier;
_thruster.transform.localScale += _scaleChange;
_thruster.transform.position += _posChange;
else if (Input.GetButtonUp("Fire3"))
_speed /= _sprintModifier;
_thruster.transform.localScale -= _scaleChange;
_thruster.transform.position -= _posChange;

We repeat the same logic for our powerup speed boost.

Thruster Speed Powerup VFX

Child gameobject position change values affected by Parent Scale

When using the _posChange on a gameobject that is a child, the values are affected by the scale of the parent gameobject.
Scale Parent: 0.5f
Child pos change in script: -0.625f
Actual value pos change: -1.25f



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store