Hey , does someone know what I should do to make a smoke trail after a rolling player ( I know it’s something to do with particles, but how ? )
Create a particle system GameObject from the GameObject menu. Then attach it to your player GameObject (by dragging in the hierarchy pane) so that it is a child of the player, and therefore moves with it.
For black smoke, create a new material, and set its shader to ‘Particles/Multiply’. Then create square image to use as the texture, with a black blurry shape centred within a white square.
(see attached texture)
Assign that your texture to your new material, and assign the material to the particle system (by dragging the material from the project view to the particle system in the hierarchy view).
Finally, adjust the size of the particles, by changing the ‘Min Size’ and ‘Max Size’ of the particles to larger values, such as 2 5.
This should give a decent simple smoke trail effect.
hope this helps!
(Edit: attached smoke particle texture)
- Ben

Yea thanks, but I know all that.
I just need the particles when I play the roll animation on my player … ![]()
Oh, well you should have said so then!
In that case set the ‘emit’ checkbox to false, and at the point at which you trigger your animation, also use the ‘emit’ property to set the emitter on for a short time, as described here:
http://unity3d.com/support/documentation/ScriptReference/ParticleEmitter-emit.html
- Ben
ok,thanks … ![]()
But could you post a simple script, my doesn’t work
It would probably bebetter if we start from the script that you already have to play the roll animation on your character.
I currently have this animation script
var rollSound : AudioClip;
function Start ()
{
animation.wrapMode = WrapMode.Loop;
animation["roll"].wrapMode = WrapMode.Once;
animation["roll"].layer = 1;
}
function Update () {
if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1)
animation.CrossFade("walk");
else
animation.CrossFade("idle");
if (Input.GetButtonDown ("Fire1")) {
if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1) {
animation.Play("roll");
}
}
}
And then I have this particle code
var emit = false;
function Update () {
// Emit particles for 3 seconds
particleEmitter.emit = true;
yield WaitForSeconds(3);
// Then stop
particleEmitter.emit = false;
}
Okay - we’ll just put them together like this:
var rollSound : AudioClip;
function Start ()
{
particleEmitter.emit = false;
animation.wrapMode = WrapMode.Loop;
animation["roll"].wrapMode = WrapMode.Once;
animation["roll"].layer = 1;
}
function Update () {
if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1)
animation.CrossFade("walk");
else
animation.CrossFade("idle");
if (Input.GetButtonDown ("Fire1")) {
if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1) {
animation.Play("roll");
StartEmit();
}
}
}
function StartEmit () {
// Emit particles for 3 seconds
particleEmitter.emit = true;
yield WaitForSeconds(3);
// Then stop
particleEmitter.emit = false;
}
I’ve put the emitter control code into a separate function called ‘StartEmit’, and that function is called at the same time as the roll animation is triggered.
- Ben
But how should this script tell the particles to be false or not ?
And it still don’t work
It won’t stop the current particles, it will just start and stop new ones being emitted.
To hide any existing particles, you can use the ClearParticles function:
http://unity3d.com/support/documentation/ScriptReference/ParticleEmitter.ClearParticles.html
- Ben
YEA, But how is the script communicate with the particle system. When I try this on my player with a particle system as a child object it just pause the game … ?
Ah okay I see the problem. The script is assuming the particle emitter is on the player GO, instead of on a child GO.
Here I have set up a var called ‘emitter’, and in the Start() function, it makes a reference to the particle emitter component on the child object:
var rollSound : AudioClip;
var emitter : ParticleEmitter;
function Start ()
{
emitter = GetComponentInChildren(ParticleEmitter);
emitter.emit = false;
animation.wrapMode = WrapMode.Loop;
animation["roll"].wrapMode = WrapMode.Once;
animation["roll"].layer = 1;
}
function Update () {
if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1)
animation.CrossFade("walk");
else
animation.CrossFade("idle");
if (Input.GetButtonDown ("Fire1")) {
if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1) {
animation.Play("roll");
StartEmit();
}
}
}
function StartEmit () {
// Emit particles for 3 seconds
emitter.emit = true;
yield WaitForSeconds(3);
// Then stop
emitter.emit = false;
}
hope this fixes it ![]()
- Ben
ok, I will try.
And thanks so much for the help ![]()
Hey it worked
So if the other script should work, the particle had to be a part of the player ( I thought it vas a bit too easy to just attach the script to the player and then it find the particle system itself
)
If someone would see the result it’s here …
The video is a little bit slow, but it runs much smother in the game ![]()