So have four wheels on a car and the car body as separate objects that are grouped in the parent object car in my Hiearchy.
I need to access each wheel and the body separately so that I can have the player paint it.
The problem is that when I call transform.parent and try to rotate, the car rotates about a large radius and not about its center.
public Renderer carBody;
public Renderer carWheel1;
public Renderer carWheel2;
public Renderer carWheel3;
public Renderer carWheel4;
void Start ()
{
carBody.material.color = Color.red;
carWheel1.material.color = Color.black;
carWheel2.material.color = Color.black;
carWheel3.material.color = Color.black;
carWheel4.material.color = Color.black;
}
// Update is called once per frame
void Update ()
{
var rotationDirection = new Vector3(0, 1, 0);
var carObject = carBody.transform.parent;
carObject.transform.Rotate((rotationDirection * Time.deltaTime * rotationSpeed));
}
I need to know how to rotate the parent around its center and not around a larger radius of rotation.
Thank you in advance.