I’m working on a grappling hook, and I want to keep a certain distance between two RigidBodies, while still letting one orbit the other. An example of what I’m looking for is the grappling hook in Floating Point. The ‘rope’ is rigid and has no give.
My current solution is to apply a force to keep it a certain distance away, but it’s really wobbly. Is there any way other than joints to do this?
if (Vector3.Distance(transform.position, contactPoint) > distanceToGrapplePoint) {
rigidbody.AddForce(contactPoint - transform.position);
} else if (Vector3.Distance(transform.position, contactPoint) < distanceToGrapplePoint) {
rigidbody.AddForce(transform.position - contactPoint);
}