Particle System Distance Rate + RigidBody 2D

Hello !
I’m having an issue with the new Unity 5.5: my particle system doesn’t emit over distance when not moved with physics if a rigidbody2D is attached to it (if I only do transform.Translate, it does Emit if my object does not have a rigidBody2D component attached), I don’t know if I am the only one but it’s troublesome !

If anyone have an idea on how to overcome this I’ll be happy !

Thanks !

This is because we now use a Rigidbody to drive the velocity of the particle system if one is attached.
Previously the particle system would calculate the velocity for itself however if a rigid body was attached then the rigibody and the particle system would have 2 different velocity values due to the 2 systems updating the values at different times(fixed update etc) which would cause particles to behave incorrectly. If you want to move the system you need to do it through the rigidbody by changing its velocity. You could also try making the particle system a child of the rigidbody, it will then calculate a local velocity based on position and apply that to the rigibody velocity which should achieve what you want.

1 Like

I see, I’ll try this, thanks for the quick reply !

1 Like

Hi,
For me it did not work to add the ParticleSystem as child to the RigidBody, but the other way round.
I use touch gestures to move a GameObject with RigidBody2D and ParticleSystem attached. The ParticleSystem emits over distance. This was broken in Unity 5.5.
I tried to make the ParticleSystem a child of the RigidBody2D as suggested above, but the emission still did not work. Now I moved the ParticleSystem back to the main GameoObject and made the RigidBody2D a child. This seems to work.
Hope this helps.

This tutorial example use to have tanks that threw dust when moving forward/backward. Now, since those changes, they only throw dust when turning: Unity Asset Store - The Best Assets for Game Making

Since this change is made “by design”: Unity Issue Tracker - [Particles] Emission over distance not working when moving parent with not non Kinematic Rigidbody/Rigidbody2D
It would be good to update the Manual: Unity - Manual: Emission module

2 Likes

If the effect does not work anymore then please report it as a bug. Although I was told about this issue with the tanks tutorial and tested it myself a month ago and it worked fine, have you tried the completed version of the tutorial?

Hi. I make the particle system a child of RigidBody, then move the RigidBody by using rigodBody.MovePositoin(), but the particle system still not work at all. I have to make the particle system “out of the RigidBody” (Not a child), and update its position in Update(), it works but this is not a good way to do like this. Is it any way to solve this?

I’m not sure I understand. Can you file a bug report with a sample project that shows this problem?

Please check the attach file.
In the example scene, I made the particle system as a child of the rigidbody object, but the particle system didn’t emit when its parent moving. (I made the rigidbody object moving by using “RigidBody.MovePosition()”)
Thanks for help:)

3022357–225820–ParticleEmitBug.rar (2.84 MB)

Hi. Can you file this as a bug report please? I can get QA to look at it then, otherwise Ill try and take a look when I get a chance but may end up forgetting about it :frowning:

Sorry for my late reply. I’ve reported a bug(900069). Thanks for your help.

1 Like

This is actually a very old bug which first occurred in my project was about 3-4 months ago. My solution was has an empty container for the two objects separately has rigidbody and particle system attached. And then move the container. It works at first place but still doesn’t make sense to me for a long time. So I googled this topic and hope this bug could be fixed asap.

Also currently going through the tank tutorial, and when moving the tank using “RigidBody.MovePosition()”, the RB component reports a velocity of 0,0,0 when i poll it with debug log. Don’t know why particles get spawned when rotating, but this depends on the particle object being off-center of the parent. If you reset xform on the particle child object, it will fail to spawn particles both when translating and rotating.

Hey guys,
I’ve sufffered with this problem when i’ve tried to update from 5.4 to 5.6, i’d searched through stack overflow and some other forums but nothing…
Then i’ve decided to solve it with the solution below.
This is happening because the particle system someway is being affected by dynamic rigidbody and it becomes directly dependent of the FPS(Try to decreace or increace and you will see it).
To resolve there are some ways, the last one is the most correct in my opinion.

1st, Create a particle that uses rate over distance out of the parent and make follow it.
(as i’ve made before like stylophone)

2nd, Put an Knematic not simulated (not affected by physics) rigidbody on the game object responsbile by the particle.

Before


After

.

In case you missed it:
https://moonflowercarnivore.tumblr.com/post/157945497336/rigid-body-and-particle-system

1 Like

Oh, i didn’t see it, but if i’m not wrog, you were changing the velocity of the gameobject to 0 on late update in your solution, right?. you were using an particle outside the rigidbody2d following target right?.
On 5.6 the boolean simulated it is in the inspector, in your video it wasn’t.
(but still in doccumentation at least from 5.0)
In my specific case, i use addforce to move my spaceship, soo i would had to do it(make particles out of them following) my spaceship and a bunch of enemies it would flood the hierarchy, using as an child inside and rigidbody with an knematic not simulated it became more clean in my opinion for my situation.

I am not entirely sure about “changing the velocity of the gameobject to 0”, but it is correct that my solution requires that the PS is not parented to any object with RB component. Because you’re copying the world position (instead of local position) of the RB object to the target PS object, it doesn’t matter where that PS object is positioned on awake.
The solution with “is knematic” was an answer I got from a Unity technician, may be Karl?
If emission over distance is functional but simply not perfectly as expected, you should instead enable any interpolation option in the RB component first.

Hi. To clarify a little.

If a particle system detects a non-kinematic rigidbody then it will use the velocity value from this instead of attempting to calculate the velocity itself.
The reason for this is because of the different update times for particles and physics which at high speeds would cause particles to calculate a different velocity from the RB and particles would fly off in the wrong direction, by staying in sync with the RB we avoid these strange issues.

If a RB is driving the velocity you will see this message in the inspector:
3038484--227472--upload_2017-4-19_14-9-37.png

In older versions the message is in the inherit velocity module but we recently moved it to the main module.

RigidBody.MovePosition() will not work as it does not update the velocity when using this(by design). So if you are using MovePosition then either mark the RB kinematic(so it’s ignored) or switch to setting the velocity instead.
For moving vehicles etc you should really be using velocity, MovePosition is for teleporting which is why velocity is ignored. I have not recently looked at the Tanks tutorial but it’s possible that the team that developed it did not realise this, which is why it is not working with particles correctly anymore.

For example the bug project submitted by @big_march .
You can fix it by setting the velocity instead like so:

    void FixedUpdate()
    {
        Rigidbody rb = GetComponent<Rigidbody>();
        //rb.MovePosition(rb.position + transform.forward * Speed * Time.fixedDeltaTime); // This won't work
        rb.velocity = transform.forward * Speed; // This will work
    }

We also detect what we call local velocity for child systems. So if a particle system is moving whilst also parented to a RB then we calculate the delta difference and apply this to the RB velocity to get the child velocity. This is why you may sometimes see particles emitted even when the RB has zero velocity.

So in summary:
-If moving a non-kinematic RigidBody then do so by setting the velocity value unless you want to teleport in which case use MovePosition.
-If the RigidBody is kinematic then the particle system ignores it and does its own calculations.

1 Like

Hey guys, sorry to resurrect this by a few months.

I was working my way through the Tanks! tutorial as well and ran into this dust trail problem. I solved it by setting the velocity as mentioned above. However, later on, when the exploding shell should have pushed the tank, it didn’t work as expected. The tank just teleported a short distance rather than appearing to roll backward.

After reading karl jones’ reply, I created another empty game object (called Dust) as a child of the Tank object. I then moved the two dust trail objects so that they were a child of Dust. I added a Rigidbody to Dust and checked “is Kinematic”. This allows the dust trails to work and the tank to be pushed back as expected by the exploding shell.

This is probably not ideal, but it gets the same behavior as the tutorial without any script changes.

2 Likes

Totally right there, I had my missiles with rigidbodies because I was instantiating them as rigidbodies from code. Therefore the particle systems stopped working from Unity 5.5.0 up.
Now I removed the rigidbodies from the missiles prefabs and instantiate them as just as GameObjects. And the particles came back again.