I have a camera setup wherein an object “tripod” has its own rotation/position and my camera is a child-object of the “tripod”. The whole point was that I should be able to isolate one axis on my camera (z) while using my tripod to point at objects (with x,y). The problem is that when i transform.Rotate(0,0,.02) (any number no matter how small), my parent object goes berzerk. It begins to inherit it’s child’s transform!
Heres my setup
Tripod
Main Camera
the tripod has the script:
using UnityEngine;
using System.Collections;
public class Tripod : MonoBehaviour {
public float smoothTime = 10.3F;
private Vector3 velocity = Vector3.zero;
float force = 30f;
public GameObject Ball;
public GameObject Campointer;
float control = 0;
void Update () {
this.transform.position = new Vector3(Ball.transform.position.x,Ball.transform.position.y , Ball.transform.position.z);
Campointer.transform.position = new Vector3(Ball.transform.position.x,Ball.transform.position.y , Ball.transform.position.z);
Vector3 targetvector = LookatThis.LookatV;
Quaternion targetQ = Quaternion.LookRotation(targetvector);
Campointer.transform.LookAt(targetvector);
transform.rotation = Quaternion.Lerp(Camera.main.transform.rotation,Campointer.transform.rotation, .03f);
}
}
All of this code and it’s incoming connections are working fine. The problem comes when I add a simple script to the camera object.
using UnityEngine;
using System.Collections;
public class CamZ : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.Rotate(0,0,.02f);
}
}
The actual camera rotate as it’s suppose to (in the inspector) but the parent starts spinning madly. It starts slowly and gets faster and faster until the screen is just a blur.
Parent objects aren’t suppose to do this… unless im missing the entire point of hierchy…
A side note… although I doubt it is relevant. my parent object is just an empty object with the name “tripod”. So a transform/rotation. I really didn’t need or want a “real” object since it would just get in the way.