- Home /
Fixed joint - not really fixed?
Hi, im trying to connect these series of cubes together as shown here :
The orange cube is fixed in its position, and all the other cubes (with gravity) are connected in a series of fixed joints. My problem is that the fixed joint don't really fix the objects in their positions, but rather "dangle" around like a spring, as shown :
How do I achieve a really fixed positions with a physics joint for all the connected bodies without the dangling effect while still enabling its "use gravity" and "is kinematic" option? I'm using javascript if it concerns anything,Thanks!
Sorry for the pictures, coudn't figure out how to post them there.
Answer by reptilebeats · Mar 24, 2012 at 03:08 AM
Your best option what i use a lot for certain things is either turn the solver iteration count up in physics to make joints more solid, however this will add performance drain as it effecting every joint in game.
Or what i normally use is a configurable joint lock all and then at the bottom u will find projection turn this on for rotation and position and underneath set the limits to 0, u may also have to turn solver iteration up a little depending on your setting.
Remember setting this can make objects react differently, for example i made a bike game and the back wheel had to have a little room on the projection in order for the bike to have the right feel when applying forces.
$$anonymous$$any thanks for saving my life! Turning the limits to 0 reduces the wiggling significantly, thanks!
Note : When changing solver iteration count, it only applies the new value on project start. I wondered why, when changing solver iteration count value, had no effect on my game, that is why.
Answer by wborgo · Jun 03, 2013 at 10:09 PM
I know this question is a little old, but, if someone have the some problem, here is my solution:
Mark all the constraints in the object's rigidbody
Create a CS file called FixJoint.cs
Attach this script in the object.
The code to FixJoint.cs:
using UnityEngine;
using System.Collections;
public class FixJoint : MonoBehaviour {
void FixedUpdate () {
if (!GetComponent<FixedJoint>())
{
rigidbody.constraints = RigidbodyConstraints.None;
Destroy(this);
}
}
}
What it does is simple: If your object have constraints it will not move, but the joint will work. So, it's check if the component is attached in your object, if not, it means that the joints have broken, so, the script will clean the constraints. After this, the script will destroy itself, cause it is not usefull anymore.
Sorry for my english, it's not my native language. William Borgo.
Answer by valeracogut-datasakura · May 16, 2020 at 04:15 PM
1st solution for this problem is to separate fixed joint physics and its graphics
2nd solution - if you cannot separate joint from graphics you can also make your joint stronger by adding new one on the same object :-)
hope these two hacks will help in your projects!
Answer by Statement · Mar 23, 2012 at 03:14 PM
Add the objects as children. This will make them "rock solid" as they will not bend, rather rotate the entire object if it gets too heavy. In this scenario you shouldn't keep the rigidbody on the child objects.
I want the objects to be individuals ins$$anonymous$$d of being a parent/childrento other objects, is there any alternative besides adding them as childrens?
physics-simulations always need some "room" to operate and handle forces. Even in the real world every material does slightly bend / move in order to transfer / absorb forces. Simulating physics isn't an easy task since the simulation happens only at fix timesteps.
You can try another joint type (ConfigurableJoint), but as already said it will never be "fix" like a parent-child-relationship.
You can keep the child rigidbodies if you make them kinematik in the case you unparent them later.
You could also try to disable the gravity on all rigidbodies so you don't have the bend-effect. If a joint breaks you could enable the gravity of the individuals to make them fall down.
Answer by gooncorp · Jun 02, 2014 at 06:10 PM
I'm pretty sure the configurable joint is broken. When you go too fast with 2 joints they always drag behind even if you set all the values to LOCKED, this is broken in my opinion. When you have to write a script that does what those LOCKED settings should have done in the first place something is def wrong.
Your answer
Follow this Question
Related Questions
Disable weight "inheritance" when using HingeJoint2D? 1 Answer
ridgid bodies of different mass 3 Answers
Is it okay to give child objects rigidbodies? 0 Answers
Ball physics help 2 Answers
make a lever with physic ? hinge or spring joint ? 0 Answers