Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Apply force to a certain element of the rope
#2
(25-08-2020, 11:53 AM)flaurens Wrote: Hi!

I'm interested on knowing how to apply a certain force to a certain element of the rope.
I let the player cut the rope by doing:

Code:
            rope.Tear(rope.elements[IndexToBreak]);
            rope.RebuildConstraintsFromElements();

What I want is to apply a certain amount of force to IndexToBreak in order to simulate that the "cut" has been produced. Right now when the rope is cut it falls normally.

I read from the documentation that I have to set the inverse mass of that element to zero and then apply the force that I want, but if I do that the element that I set its mass to zero gets freeze. What is the best approach in that case? Save the previous mass, set mass to zero, apply force and then set mass to the previous value?

Reagrds!

Hi,

First of all, elements and particles are not the same thing. An element is an "edge" linking two particles. You can't set any properties on an element, but you can set properties of any of the two particles at both ends.

Now, to apply a force to a particle you can't set the inverse mass to zero. Setting the inverse mass to zero essentially deactivates physics, and allows you to directly set the position of a particle without dynamics modifying it. This is what the manual says:

Quote:An inverse mass of 0 means the particle's mass is infinite, so its position will be unaffected by dynamics (allowing you to override it manually).


A force however, does not directly affect the position of a particle. Remember that force = mass * acceleration. Just write the force vector in the solver.externalForces array at the indices indicated by the rope element. That should do it.
Reply


Messages In This Thread
RE: Apply force to a certain element of the rope - by josemendez - 25-08-2020, 12:34 PM