Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parent Movement
#1
Hello,

In my scene, there is a normal rotating cylinder and softbody spheres arranged around this cylinder. In order to attract the center of the cylinder, I apply a force to all spheres as follows:


Code:
var forceDirection = (spin.transform.position - transform.position).normalized;
softBall.AddForce(forceDirection * force, ForceMode.Acceleration);


But at the same time, the cylinder is the parent object of these spheres. And when I rotate the cylinder, I want these spheres to rotate with the cylinder, like normal spheres. But they don't rotate, I can only see the strain vibration. They can rotate when I turn off the softbody features, but I shouldn't turn them off.

The rotation code of the cylinder is as follows:


Code:
transform.Rotate(Vector3.forward,-_inputVector.x*spinRotateSpeed);


I use the solver and sphere softbody features in the sample scene named BallPool.

Thanks.
Reply
#2
Hi,

Don't parent the individual softbodies to the cylinder, instead parent the ObiSolver component. Since simulation is performed in the solver's local space, the softbodies will rotate long with the cylinder.

kind regards,
Reply
#3
(28-02-2024, 10:45 AM)josemendez Wrote: Hi,

Don't parent the individual softbodies to the cylinder, instead parent the ObiSolver component. Since simulation is performed in the solver's local space, the softbodies will rotate long with the cylinder.

kind regards,


Thanks, this worked. But while spinning, the spheres scatter around and do not come back. And where it stops, it slides around the cylinder. How can we keep it stable? Is there such a thing as resetting the force on it? It's like resetting the velocity of normal physics. I read something like particle attachment somewhere, but I couldn't run its full implementation, like in rope physics.
Reply
#4
(28-02-2024, 12:22 PM)BusraSevim Wrote: Thanks, this worked. But while spinning, the spheres scatter around and do not come back. And where it stops, it slides around the cylinder. How can we keep it stable? [...] I read something like particle attachment somewhere, but I couldn't run its full implementation, like in rope physics.

So you want the softbodies to rotate together with the cylinder, and not slide over its surface right? sounds like you just want to attach the softbodies to the cylinder...

You use a ObiParticleAttachment for that. It works just like it does for ropes, only difference is you need to create particle groups in the softbody blueprint editor to determine which particles in the softbody you want to be attached. See: http://obi.virtualmethodstudio.com/manua...ments.html

Quote:Particle group: The particle group you want to keep attached to the target. For cloth and softbodies, you can define new particle groups in the blueprint editor. Ropes and rods automatically generate a new group for each control point in the blueprint's path.

(28-02-2024, 12:22 PM)BusraSevim Wrote: Is there such a thing as resetting the force on it? It's like resetting the velocity of normal physics.

Not sure why you would want to do this in this case, however you can access all per-particle data (including velocities) using the particles API.

kind regards,
Reply
#5
(28-02-2024, 12:26 PM)josemendez Wrote: So you want the softbodies to rotate together with the cylinder, and not slide over its surface right? sounds like you just want to attach the softbodies to the cylinder...

You use a ObiParticleAttachment for that. It works just like it does for ropes, only difference is you need to create particle groups in the softbody blueprint editor to determine which particles in the softbody you want to be attached. See: http://obi.virtualmethodstudio.com/manua...ments.html



Not sure why you would want to do this in this case, however you can access all per-particle data (including velocities) using the particles API.

kind regards,

Thanks, this worked too, but it doesn't give me the result I wanted. Since it is locked to a point, its position does not change at all. However, objects coming from above should be able to push this object left and right. In the first image I posted, the balls come down from above and settle properly, except for the pink balls slipping away. In the second image, there is a scene view of the first image. The third image shows the image that occurs when I rotate the cylinder a little. Idont want this. Attachment also works, but it doesn't give me what I want. I asked about velocity resetting, thinking that if I reset all the forces on the sphere before applying force, I could avoid this. But it wasn't very healthy either. Is what I want possible with obi softbody? The solutions that come to my mind usually explode for other reasons. The simplest way is to create a separate solver for all of them and make the movement completely by gravity, as it rotates, it is automatically pulled in. But this is not healthy either, and as far as I have read, particles that are not under the same solverdo not detect each other, and I need to detect each other.


Attached Files Thumbnail(s)
           
Reply
#6
(29-02-2024, 09:00 AM)BusraSevim Wrote: The third image shows the image that occurs when I rotate the cylinder a little. Idont want this.

Is the solver transform centered at the cylinder (that is, is its local position 0,0,0?). Also, are both linear and angular inertia scale parameters in the solver set to zero, so that rotating/moving the cylinder doesn't inject world-space inertia?

(29-02-2024, 09:00 AM)BusraSevim Wrote: Attachment also works, but it doesn't give me what I want. I asked about velocity resetting, thinking that if I reset all the forces on the sphere before applying force, I could avoid this. But it wasn't very healthy either. Is what I want possible with obi softbody?

Parenting the solver to the cylinder and using attachments are both designed to allow for perfect rotation, but I think you just want to add an acceleration towards the cylinder for each softbody, and apply a material with friction to the cylinder collider and/or the softbodies. This way when the cylinder rotates, the softbodies in contact with it will rotate too due to friction - with no friction, they will just freely slide on top of it.

See the "ObstacleCourse" sample scene, the rotating platforms at the end of the course make the softbody ball rotate when on top of them, this doesn't involve either parenting or attachments but only friction.

Same approach would work for rigidbodies, by the way.

(29-02-2024, 09:00 AM)BusraSevim Wrote: The simplest way is to create a separate solver for all of them and make the movement completely by gravity, as it rotates, it is automatically pulled in. But this is not healthy either, and as far as I have read, particles that are not under the same solverdo not detect each other, and I need to detect each other.

You don't need separate solvers to have individual, per-softbody (or even per-particle) gravity. Gravity is just an acceleration, you can either use softbody.AddForce with acceleration mode or modify the velocity of each particle using the particles API.

The gravity value in the solver is only there for convenience, it applies the same acceleration to all particles managed by the solver - which is the most typical use case.

Again, the same thing would work for rigidbodies: no need to have separate physics scenes in Unity to have per-object gravity.

kind regards,
Reply