particleEmitter.localVelocity += rigidbody.velocity.z

gameObject.Find("ShotFire").particleEmitter.localVelocity += rigidbody.velocity.z.magnitude;

I have a car that can shoot with fire (using particle system to show flames and ray cast to detect if it hits objects). If car moves very fast forward, flames get blown away behind the car. And my ray 10 meters ahead the car still burns objects.

So, to fix this I tried the code above or variations of it, but console says that its impossible, because one is of float type and other is Vector3. Didn’t find a way to turn Vector3 into float.

I’m not using force on particle system, I’m using local velocity z = 20.

The rigidbody’s velocity is a vector but the individual XYZ components are floats. To shoot the flames out forward, I would suggest you do something like:-

gameObject.Find("ShotFire").particleEmitter.localVelocity.z = rigidbody.velocity.magnitude + speedOfFlames;

The forward speed of the rigidbody is given by the magnitude of the velocity, but the particle emitter’s forward speed is its local Z component.

Perfect! Andeeee, you’re my life saver.

Thanks a lot!