- Home /
how to make particles activate when object moves
hello I have a very good Question for you smart scripters, since I don't do scripting (only modeling) I have come back to the community for answers. My question is how do you create a script the activates particles when a object with this script starts to move and deactivates when it stops moving.
If you guys could help me with this that would be great.
Thanks. ,
It would be helpful if you would include the actual movement script.
Answer by aditya · Dec 17, 2016 at 11:12 AM
For two cases ...
If your object is a rigidbody then check for Rigidbody.velocity, if it is more than zero it means your object is moving, if zero than it is still
If your object is not a rigidbody then check for its current and old position in each frame (or in whatever manner you want it to happen), if current and old positions are same than it is still, else its moved
Accept if it solved your problem
And if it uses CharacterController you can check for characterController.velocity.magnitude > 0
ok so it has a rigidbody. just to let you know. what it is, is a ship so what I'm trying to figure out is how to create a script in JS that would activate on the particles when the Rigidbody starts to move.......so what your saying is that if I use Rigidbody.velocity it would activate the particle system in the prefab. When its moving of course. :P
Yes?
Rigidbody.velocity will return you a value and you had to check if that value is more than 0 then play the particles if it is equal to 0 then stop the particles
ok so it has a rigidbody. just to let you know. what it is, is a ship so what I'm trying to figure out is how to create a script in JS that would activate on the particles when the Rigidbody starts to move.......so what your saying is that if I use Rigidbody.velocity it would activate the particle system in the prefab. When its moving of course. :P
Yes?
Answer by ifurkend · Dec 26, 2016 at 01:29 PM
Actually you can achieve similar effect without script by using "emission over distance" (keep in mind this is mildly broken in Unity 5.5.0 and awaits next patch) instead of "emission over time", so particles are only generated when the object moves.
Answer by Bren0831 · Dec 19, 2016 at 08:30 AM
I would try instantiating the particles if your movement input is down. Also look into line renderers if that is the kind of thing you are looking for.