[Shuriken particle] Emission over Distance/Inherit Velocity and RigidBody

@richardkettlewell @karl_jones
When I add a RigidBody component to my game object, the particle system attached to it with Emission over Distance or Inherit Velocity module (in either “current” or “initial” modes) shows the message “Velocity is being driven by Rigibody” and are not functional while dragging the rigidbody object around. While I can enable “Is Kinematic” in the RigidBody component to make Emission over Distance and Inherit Velocity functional, but then the game object does not collide now so this is not a solution.

After a quick search this is the ugly truth I’ve discovered:

Please Unity, provide a ready-to-use solution in the editor, not telling us to write a script ourselves with vague hint. I have no clear idea how to “update the Rigidbody velocity value to match the dragging action” correctly. I tried RigidBody.velocity = transform.position; in FixedUpdate() but the result is a far cry from dragging the object without RigidBody component.

Hi,
Is the problem that you want to drag the particle system while not playing?
We should be able to do something, perhaps only use the RB velocity when playing.
I’ll speak to Richard tomorrow.

No. This is happening while playing and not playing the scene. I am not gonna file a bug report because there is already one marked “by design”.

Attached a simple prefab to illustrate the problem:
Drag the parent “Test rigidbody object with particle system” and no particles emitted, unless you drag “Particle System parent” child.

2973662–220961–test rigidbody with pacitcle system.unitypackage (12.9 KB)

We are able to fix the issue to allow dragging to work in Edit Mode, for previewing purposes. I will make this change.

However, fixing this in Play mode would require a new UI option, to allow you to choose where emitter velocity comes from (Rigidbody velocity, or Transform movement) Note that taking velocity from Transform movement is far less accurate, and is prone to cause discontinuities at higher velocities, and when further away from the world origin.

I’m not sure there is a valid use-case presented here for requiring this functionality in Play Mode.

Unrelated: have you seen our new Tags system? You don’t need to guess at the correct developers to ping, you can now add Tags to your posts, eg there is a Particles tag. (See the button underneath the Thread subject). I will add the Particles tag to this post as an example.

2 Likes

Does that mean we should use RigidBody.position instead of Transform.position? If that’s that case, is it possible to make this instruction appears after “velocity being driven by RB” in inherit velocity module and also the same complete message in emission module when rate over distance is given non-zero value?

Furthermore, is it possible/constructive to have an option in the RB component which allows modifying RB.position instead of Transform.position in the transform component?

I’m not sure I understand the question. The particle system will read the velocity from the RigidBody. So whatever impacts that value will influence it. So using Addforce or setting the velocity directly will work. If you use something like MovePosition then the rb will not update the velocity from this(by design). So if you want to drag a rigid body then I would assume that whilst the dragging is occurring you do not want the rb to be applying forces or velocity, so one solution is to switch the rb off during dragging operations and then re enable it once complete. Whilst the rb is off then the particle system will revert to calculating the velocity using the position delta.
By disable I mean set the rigidbody to be kinematic.

1 Like

OK thanks for clarification. Actually I’ve checked that even RB.position does not work either because it does not translate into velocity.

Hi Richard,

The option to ignore the RigidBody velocity would actually be really useful for us.

In my use case, I can’t remove the Rigidbody or set it to be kinematic (2 kinematic RBs won’t send collision events) which means that there is no way to use the Emission Over Distance feature :confused:

I am using a third party character controller (Super Character Controller) for general movement. The character is moved directly via “transform.position”.

A Unity standard capsule and Rigidbody is also on the player object so I can use Unity’s OnCollision events against other obejcts. The Rigidbody needs to be non kinematic so the events actually fire (other objects in the game are all kinematic).

I have constrained all the position and rotation of the RB so the physics system does not interfere with my character controller.

The particle system is a child of the player object (and thus a child of the GO with the Rigidbody on it).

I did try setting the velocity of the RB through script, but due to the position constraints, it never updates.

Cheers,

Niall

Thanks for the example! You’ve convinced me that this would be useful :wink:

I’ll get it added!

1 Like