Reputation: 11
Why this two same objects show different behavior?
objects:
one
: parent Sphere1 (rigidbody use gravity)
-child Cube1
two
: parent Cube2 (rigidbody use gravity)
-child Sphere2
In this situation, I think that their center of mass is same position.
However object one
is stable, on the other hand two
is unstable(rolling down).
this problem is solved
this problem cased by script attached parent object.
To tell the truth, I've attached center of mass script to the both parent object.this script set center of mass at the center of object attached this one ,not the center of the two objects. After removing the scripts, both objects fell down.
using UnityEngine;
using System.Collections;
public class centerOfMass : MonoBehaviour
{
Vector3 center;
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
center = rb.centerOfMass;
}
void Update()
{
Debug.DrawLine(transform.position, transform.position + transform.rotation * center);
}
void OnDrawGizmos()
{
rb = GetComponent<Rigidbody>();
center = rb.centerOfMass;
Gizmos.color = Color.red;
Gizmos.DrawSphere(transform.position + transform.rotation * center, 0.08f);
}
}
Upvotes: 1
Views: 808
Reputation: 27341
As my test, both of them fall.
Do you forget add a rigidbody on the first sphere?
Upvotes: 0
Reputation: 7605
When a GameObject is a child of another one, the child will follow the parent. And if the parent is not in the ground and is affected by gravity, the parent will fall down to the ground and the child will follow.
In your cases:
On the left the Sphere (the parent) is already in the ground so it will not move from there, and the box (the child) will not make any effect.
On the right, it is the Box the parent and it is in the air, not in
the ground, so it will until it touched the ground. The sphere will
follow.
Upvotes: 1