I have a couple of questions concerning the physics
First of all, my gamobjects contains a rigidbody, mesh collider, configurable joint.
Basically, I have five boxes on the ground. I drag with the following script;
IEnumerator OnMouseDown()
{
Vector3 screenSpace = myCamera.WorldToScreenPoint(transform.position);
Vector3 offset = transform.position - myCamera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenSpace.z));
while (Input.GetMouseButton(0))
{
//if there's gameobject above the one we click make them child so that we can move then together
CreateChildParent();
Vector3 oldPosition = transform.position;
Vector3 curScreenSpace = new Vector3(Input.mousePosition.x, Input.mousePosition.y, (screenSpace.z + GETInFRONT)); // getInFront is to make sure that the block stays infront.
Vector3 curPosition = myCamera.ScreenToWorldPoint(curScreenSpace) + offset;
transform.position = curPosition;
if(oldPosition != curPosition)
{
pieceClicked = true;
}
yield return null;
}
}
So, of course, I can stack them. I can move part of the stack by clicking on one box and the ones above will become the childs of the clicked gameobject. Everything works fine from there. But if I move the stack of gameobjects slowly, the ones on top will start to go through each other.
Also, when I let go of the mouse, the boxe will fall on it’s intended position. If there’s a box already there, it will go and place itself on top of it. Normally, it will fall on it with little physic reaction and be stable in short, very short period of time. But once in a while, when I drop a boxe on top of other boxes, they will fly in different direction like firework??!!??? :?
This is a bit frustrating because it cause some instability for what seems simple to do. Can someone clarify this for me. I’m I missing something?.
*****You will find the gameobject that I’m using in attachment with the script.