- Home /
Particle system thruster to move in opposite direction to ship - non Rigidbody
Hi,
I'm trying to make my particle system thruster move in exactly the opposite direction to an object that I am dragging with the mouse (not using Rigidbodies). The particle system is a child object of the ship. Currently, I'm changing the Velocity Over Lifetime values and setting them the opposite direction to that of the ship. It's working well in terms of changing to the correct direction, however, it's changing the direction of all of the emitted particles in the system, rather than just the 'new' ones being emitted at the back of the ship.
Any help would be great - current code:
public GameObject Particles;
private ParticleSystem pSystem;
private ParticleSystem.VelocityOverLifetimeModule velocityModule;
Vector3 prevPos;
private void Start()
{
pSystem = Particles.GetComponent<ParticleSystem>();
velocityModule = pSystem.velocityOverLifetime;
}
private void LateUpdate()
{
Vector3 dir = (transform.position - prevPos);
prevPos = transform.position;
velocityModule.x = -dir.x;
velocityModule.y = -dir.y;
velocityModule.z = -dir.z;
}
I don’t think you need scrit to rotate the particle sys (ps) object. Just make sure the ps is using world simulation space. If you want the thruster particle emitted relative to the ship speed, use small negative inherit velocity (eg -0.2) of the ps. Otherwise use velocity over lifetime set to local space and give some negative value to the local z axis.
Thanks for the suggestion ifurkend - this did the trick!
Answer by brendanperry05 · Jul 31, 2018 at 05:59 PM
Change the simulation space from local to world.
Your answer
Follow this Question
Related Questions
Change velocity direction 1 Answer
Velocity with (unit vector) * (value) problem 1 Answer
Set Object Rotation based on Collision (2D) 0 Answers
How to use local angular velocity? 1 Answer
NSEW Direction of Rigidbody Velocity 3 Answers