Stop of rotation - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Softbody (https://obi.virtualmethodstudio.com/forum/forum-12.html) +--- Thread: Stop of rotation (/thread-3543.html) |
Stop of rotation - mrsloom23 - 30-07-2022 Hello. Please forgive me for my English. I use Google translate. I would like to smoothly stop the rotation of my soft body. I read the documentation and looked at the examples, but I didn't find a suitable solution. I tried to solve the problem using an array of starting positions of particles. When the button was pressed, I tried to set each particle a speed in the starting direction. Alas. It didn't work out for me. My body must constantly fall, hitting other objects. I would like to stop its rotation by pressing a key. Tell me, is it possible? Thank you in advance, josemendez. RE: Stop of rotation - mrsloom23 - 30-07-2022 You know, I kind of did it. I'm not sure if this is working correctly. But it seems to be working. Is it right? Code: if (Input.GetKey(KeyCode.Space)) RE: Stop of rotation - josemendez - 01-08-2022 (30-07-2022, 02:33 PM)mrsloom23 Wrote: You know, I kind of did it. I'm not sure if this is working correctly. But it seems to be working. Is it right? Hi there! You're adding a position delta to a velocity, which doesn't make any sense: velocities are expressed in meters per second, while a position delta is just meters. Moreover, assuming startingRot[] contains particle positions at the start, this would not stop only rotation but all particle movement. So in the general case, this won't work. Unlike rigidbodies, softbodies do not rotate around a single point/axis: each individual part of the softbody may rotate around a different point/axis at a different velocity (this is what makes it soft, if all parts moved in unison around a single point it would be rigid), so first you need to specify what do you mean by "stopping rotation". I assume you mean to stop overall rotation around the center of mass? If so, you need to calculate the softbody's center of mass, calculate angular velocity around this position, and then apply a torque (rotational force) that opposes this rotation. Obi includes helper functions for 2 of the 3 steps: Code: // calculate mass and center of mass: |