# Hinge Joint? Unconstrained.

 0 Basically I want to have a connection between two (preferably not rigidbodies but if it needs a joint I can make a workaround) GameObjects. think of a rope, but it doesn't have to be rendered or have segments. When the two objects are connected if one object moves past the rope length it will either pull the connected object with it (if the other object isn't static) or pull the object back to the connected object. more ▼ asked May 26 '11 at 09:41 AM themusicdork 46 ● 3 ● 3 ● 5 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 All joints only works with rigidbodies since they have to add forces to both attached objects. You can set one of them to be kinematic, but the other one have to be non kinematic. Otherwise it will bypass physics simulation.A Hinge Joint isn't a slider. it normally have a constant length (which can stretch a bit due to spring property). It sounds like you want just to limit an object to move further away.If you don't use rigidbodies and joints, you can handle the case yourself. Is the one point at a fix position? If so the object that moves away just needs to check the distance and move it back until the distance is ok. ``````//C# public Transform fixPoint; public Transform movingPoint; public float maxDistance = 10.0f; void Update() { Vector3 dir = fixPoint.position - movingPoint.position; float dist = dir.magnitude - maxDistance; if (dist > 0) { movingPoint.Translate (dir.normalized * dist * Time.deltaTime,Space.World); } } ``````If both points can be moved it gets a bit tricky. If you want the same behaviour like the HingeJoint you just need to affect both points (the second point just in the opposite direction). That would enable one point to pull the second point towards he's moving.If it should not pull the other object the above script should only be executed for the point that is moving. If both can move you have to switch the two points. more ▼ answered May 26 '11 at 10:02 AM Bunny83 45.3k ● 11 ● 49 ● 207 Well I can simply parent the object to a temporary rigidbody if using joints is easier.But yeah, I want a hinge joint that instead of keeping the object at a certain distance, keep it in a certain distance. So if the object is moving toward the object it is connected to, it will move freely until it get to the max distance. (at which point they will spring together)I thought a spring joint would be easier but they are retarded. (when you create one it uses the starting positions instead of the current ones). P.s. I was hoping for it not to "snap" back but for it to be pulled back. May 26 '11 at 10:22 AM themusicdork If you want it that way you can use the script above. It behaves like a spring. The "force" grows proportional to the distance, but only if it's greater than the maxDistance. You can move the object within the sphere with a radius of maxDistance freely. Only if it gets outside this script will "pull" it back. If you don't want the smooth return over time you can use LateUpdate and remove the Time.deltaTime. That way it's a hard stop at the sphere border. May 26 '11 at 11:48 AM Bunny83 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email:

Topics:

x1874
x1792
x146
x84
x46
x36

asked: May 26 '11 at 09:41 AM

Seen: 2495 times

Last Updated: Jun 09 '11 at 08:10 PM