Question by
Ponchovie · Feb 10 at 03:11 PM ·
rigidbodyrigidbody.velocityrigid body
How could I enact two forces on a rigidbody?
I'm trying to have two forces acting on the same rigidbody. One force pulls one way, and another force pulls another way, to have a kind of tug-of-war effect. I'm currently trying to implement this by changing and adding to the rigidbody's velocity directly, but that only allows the first force to pull. Is there a better way I could do this or do I just need to change my code? (Code below)
(part and rb, which are a transform and a rigidbody, is the object being pulled)
rb.velocity += 5f * (transform.position - part.transform.position);
(dragOBJ is the same object, dragPos is the location its being pulled to)
dragOBJ.velocity = (5*Vector3.Distance(dragPos.position, dragOBJ.position))*(dragPos.position - dragOBJ.position);
Comment