04-11-2021, 08:24 AM
(This post was last modified: 04-11-2021, 09:03 AM by josemendez.)
(04-11-2021, 08:06 AM)lacasrac Wrote: How can I improve it to a better way? It is now not so good at the moment
Mass is really important in pendulums. What's the mass of each rope particle, and the mass of the objects at its end? Right now it looks like the weight at the end has similar (or less) mass than the rope. This results in the rope swinging freely (as if nothing was attached to it) and the object at the end is so light that it just gets carried by the rope effortlessly: think of a paper ball attached at the end of a iron chain.
The object at the end should be heavy enough for the rope to be taut, and be able to drive the rope movement.
Needless to say, the object at the end must be a non-kinematic rigidbody attached to the rope using a dynamic attachment. Otherwise the rope will just ignore the object and move on its own, so you won't have a pendulum but merely a rope. Your code looks like it just applies some velocity to the last particle: this isn't a pendulum and won't behave like one no matter how much you try. See:
https://www.physicsclassroom.com/class/w...lum-Motion
Quote:A simple pendulum consists of a relatively massive object hung by a string from a fixed support. It typically hangs vertically in its equilibrium position. The massive object is affectionately referred to as the pendulum bob. When the bob is displaced from equilibrium and then released, it begins its back and forth vibration about its fixed equilibrium position.
Edit: Here's a video comparing a pendulum where the object at the end is heavier than the rope (left one) and another one where both have the same mass (right one). As you can see the left one swings much more nicely and the rope is kept taut at all times.