07-12-2025, 12:35 PM
(This post was last modified: 07-12-2025, 12:38 PM by josemendez.)
(06-12-2025, 09:37 PM)Aroosh Wrote: Hello
I am trying to set the velocity of cloth particles to 0 so that there is no more movement with the following code:
Hi Aroosh,
Setting the velocity of an object to zero won't keep it from moving: it will just get rid of momentum, but if there's any forces/accelerations acting upon the object (such as gravity, for example), the object will immediately continue moving. This is true both in the real world as well as any physics engine.
If you want an object to stop moving, you want the make sure no force/acceleration can affect them. This is done by giving it infinite mass, which in Obi is done by setting the particle's inverse mass to zero as explained in the manual. Setting external forces/torques to zero does absolutely nothing since these are external to the simulation - forces you want to add to the simulation, but things like gravity will still affect the particles.
Also note that cloth particles don't use any rotational information (only softbody and rod particles do) so torques and angular velocities aren't playing any role here either.
Code:
for (int i = 0; i < actor.solverIndices.count; i++)
{
int solverIndex = actor.solverIndices[i];
actor.solver.velocities[solverIndex] = Vector3.zero;
actor.solver.invMasses[solverIndex] = 0;
}(06-12-2025, 09:37 PM)Aroosh Wrote: It works when damping is set to 0.5 but when I reduce the damping I see particles start to move again.
This is because a high damping factor will keep the particle's kinetic energy below the solver's sleep threshold, putting the particle to sleep.
kind regards,

