Script in Unity3D to Make an Engine’s Glow Pulsate

Pulsating Engine Glow

I finally got around to making the engine’s glow pulsate on my ship in Unity3D for my Super Space Trooper indie video game I hope to get on the PlayStation network.  You can find the script source code below if you’d like to use it for your project.


You can change the ‘player’, ‘growSize’, and ‘duration’ to be public instead of private variables if you’d like to assign them in the Inspector.

The ‘duration’ variable is the time for an entire cycle to occur, meaning for the pulse to become large and then back to the original size again.  I used 0.15 seconds.

The ‘growSize’ variable is what determines how large the glow will become.  I used 1.2 for my needs as the engine glow didn’t need to change all that much.  Just enough to make it feel less static.

I do the changes in the LateUpdate() but you could do it in Update() or elsewhere.

/* Written by Cassius Adams for the Super Space Trooper video game. */
This script makes the engine glow pulsate.  It should be used on a transparent
material with alpha channel.  Change the 'growSize' variable to make the engine
glow grow proportionally in scale
private var startTime : float = 0; 		// Time that the resize begins at
private var minGlowSize : Vector3; 		// The minimum size of the engine glow
private var maxGlowSize : Vector3; 		// The maximum size of the engine glow
private var player : Transform; 		// The Player gameObject's transform
private var growSize : float = 1.2; 	// The size the engine glow grows to become
private var duration : float = 0.15; 	// The amount of time the engine glow takes to shrink and then grow
function Start() {
	player = GameObject.Find("PlayerObjectName").transform; // Find the Player's transform and assign it
	minGlowSize = transform.localScale; // Get the current size of the engine glow (this should be the small size)
	maxGlowSize = minGlowSize*growSize; // Assign the maximum size of the engine glow
	startTime = Time.time; // Keep track of time so we can change the duration
	duration = duration/2; // So that it's in cycles per second
function LateUpdate() {
	if(player) {
		var timer = (Time.time - startTime) / duration;
		transform.localScale = Vector3.Lerp(minGlowSize, maxGlowSize, timer); //
		if(timer >= 1) {
	    	startTime = Time.time;
	    	/* Now that it's the maximum size, reverse the order so it shrinks again */
	    	var tempMinGlowSize = maxGlowSize;
	    	maxGlowSize = minGlowSize;
	    	minGlowSize = tempMinGlowSize;


Please feel free to use this script for your project.  I’d appreciate credit for the work but don’t feel obligated.

Posted in Javascript JS, Super Space Trooper, Unity 3D, Video Game Development
One comment on “Script in Unity3D to Make an Engine’s Glow Pulsate
  1. Daniele says:

    Hey, if you need to animate properties with Unity, you might also want to try HOTween. Free and quick to implement :) (and yes, I built it, but I’m suggesting it only for its usefulness, not for pedant advertising :P)

1 Pings/Trackbacks for "Script in Unity3D to Make an Engine’s Glow Pulsate"
  1. […] player’s ship a bit.  It still needs quite a bit of work, but for now I just added in the glow of the engines which I hadn’t done yet.  I did it by resizing a plane that has the glow texture on it.  […]

Leave a Reply

Your email address will not be published. Required fields are marked *



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>