Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Pull particles in a given direction
#1
Hello!
We would like to move a “liquild” bulge along the rope but with a few nuances.


First I’ll describe what we tried. We tried putting a ring-like collider on a rope and moving it along the rope with force. But the ring would get stuck where the rope bends and at places where a particle is attached with ObiParticleAttachment.


We also tried building a level with two ropes and a ball going between them. But it negatively impacted performance and the ball would still get stuck at ParticleAttachments.


We then saw your post where you referenced the hose example (http://obi.virtualmethodstudio.com/forum/thread-2539.html). It could work for us but we can not quite figure out how to hook it up with player input.
Simply put, the bulge should follow the mouse position, but if the player tries to pull the bulge “outside” the rope, doing so should pull the rope (see picture for a graphic explanation).


I assume it could be implemented similar to ObiRopeAttach.cs example. But the question is, is it possible to pull particles in a given direction? Any other advice on the matter would be appreciated too.


Thank you!


Attached Files Thumbnail(s)
   
Reply
#2
Hi there,

Code:
But the question is, is it possible to pull particles in a given direction?

Yes. You can do basically anything you want with particles, since you have read/write access to all their properties: position, velocity, radius, mass, etc. See:
http://obi.virtualmethodstudio.com/tutor...icles.html

Code:
First I’ll describe what we tried. We tried putting a ring-like collider on a rope and moving it along the rope with force. But the ring would get stuck where the rope bends and at places where a particle is attached with ObiParticleAttachment.

That won't work well, since you're relying on collision detection just to keep the "bulge" on top of the rope. You're starting with an object that has 6 degrees of freedom (3 translational, 3 rotational), but you really only want 1 degree of freedom: translation along the rope.

It's easier, faster and more robust to work in a way that you only have 1 degree of freedom, compared to having all 6 and then trying to remove 5 of them trough contacts/collisions/constraints of some kind.

Code:
We then saw your post where you referenced the hose example (http://obi.virtualmethodstudio.com/forum/thread-2539.html). It could work for us but we can not quite figure out how to hook it up with player input.
Simply put, the bulge should follow the mouse position, but if the player tries to pull the bulge “outside” the rope, doing so should pull the rope (see picture for a graphic explanation).

Bulging in the hose example works by changing particle radius using a sine wave. You can simply change the center of the sine using input. This way the bulge can only move along the rope, there's no need to remove degrees of freedom since it only has 1 to begin with.

When the wave is sitting on top of the first or last particle, altering that particle's velocity will allow you to move it around.

Will whip up an example of this if you need.

cheers,
Reply
#3
Thanks for your reply, it was quite helpful!
We have another question, sorry to bother you.
Suppose we would change the rope radius at a given particle. Is it possible to change the center position? I'm not sure how to phrase this but I hope the image gives an idea of the effect we are looking for. We want the bulge to be a little bit to the side of the rope.


Attached Files Thumbnail(s)
   
Reply
#4
(24-05-2021, 02:08 PM)xkalibrx Wrote: Thanks for your reply, it was quite helpful!
We have another question, sorry to bother you.
Suppose we would change the rope radius at a given particle. Is it possible to change the center position? I'm not sure how to phrase this but I hope the image gives an idea of the effect we are looking for. We want the bulge to be a little bit to the side of the rope.

Hi,

Sure. Just set the position of the particle, in addition to setting its radius.

Say the radius of the particle was originally 1, and is now 1.5 after bulging. You can move it 0.5 units (newRadius - oldRadius) in any direction perpendicular to the local tangent vector to achieve this effect.
Reply
#5
(24-05-2021, 02:19 PM)josemendez Wrote: Hi,

Sure. Just set the position of the particle, in addition to setting its radius.

Say the radius of the particle was originally 1, and is now 1.5 after bulging. You can move it 0.5 units  (newRadius - oldRadius) in any direction perpendicular to the local tangent vector to achieve this effect.

When I set particle positions the rope shakes terribly, I assume this is because the solver pulls those particles back. Is that correct? If so, is there a way to counteract this?

We have distance, bending and particle collisions constraints enabled in our solver in case that matters.
Thank you again!
Reply
#6
(25-05-2021, 10:21 AM)xkalibrx Wrote:
When I set particle positions the rope shakes terribly, I assume this is because the solver pulls those particles back. Is that correct? If so, is there a way to counteract this?

We have distance, bending and particle collisions constraints enabled in our solver in case that matters.
Thank you again!

Setting the position of a particle will affect all neighboring particles indeed, since they're linked to each other trough constraints. These are updated as part of the physics simulation, in FixedUpdate(). You can't disable these, as the rope will stop behaving like a rope.

Depending on where in Unity's update cycle you're setting particle positions, this can cause jitter as FixedUpdate and Update are called at different frequencies. Physics-related stuff should always be updated in FixedUpdate.

Also depending on what your needs are, maybe all you need to displace is the rope's mesh, and not particles themselves. This can be done by modifying ObiRopeExtrudedRenderer.cs to move path frames (ObiPathFrame structs) around prior to building the mesh. Consider whether this is feasible in your case.
Reply
#7
Quote:
Physics-related stuff should always be updated in FixedUpdate.
Yes, this is how we do it.
Quote:
Also depending on what your needs are, maybe all you need to displace is the rope's mesh, and not particles themselves. This can be done by modifying ObiRopeExtrudedRenderer.cs to move path frames (ObiPathFrame structs) around prior to building the mesh. Consider whether this is feasible in your case.
Hm, no, I'm afraid this is not. See, this bulge should be able to collide with rope, the rope should behave like a rope too.
Maybe we can change collision detection radius at a given particle?
Reply
#8
(25-05-2021, 11:34 AM)xkalibrx Wrote: Yes, this is how we do it.

Can't reproduce any jittering when setting the positions myself. Would it be possible for you to share your code?

(25-05-2021, 11:34 AM)xkalibrx Wrote: Maybe we can change collision detection radius at a given particle?[/font][/size][/color]

That's what you're *already* doing, I assume? the particle's principal radii are the collision radii. Particle radius == collision radius.
Reply
#9
(25-05-2021, 12:26 PM)josemendez Wrote: Can't reproduce any jittering when setting the positions myself. Would it be possible for you to share your code?


That's what you're *already* doing, I assume? the particle's principal radii are the collision radii. Particle radius == collision radius.


Perhaps i misunderstood your first advice on this matter and began to move what was not needed))

We have a radius of certain points. as the radius increases, it increases in both directions. We need to do this if the player moves his finger towards the wall. The bulge on one side increased, and on the other it decreased. Of course, within reasonable limits, which we can customize.

Attached is a picture of what I want to receive


Attached Files Thumbnail(s)
   
Reply
#10
(25-05-2021, 12:29 PM)xkalibrx Wrote: Perhaps you misunderstood your first advice on this matter and began to move what was not needed))

We have a radius of certain points. as the radius increases, it increases in both directions. We need to do this if the player moves his finger towards the wall. The bulge on one side increased, and on the other it decreased. Of course, within reasonable limits, which we can customize.

That's basically what particles do by default. The bulge will move according to what it is colliding against, eg: if it has a wall on its right side, it will move to the left. The right side of the rope will be flat against the wall, and the left side will bulge out.

As I pointed out, particle radius is the collision radius. If you've changed the radius, this is the behavior you'll get by default (unless you've got collisions deactivated).
Reply