In my game i'm trying to rotate the x-axis of the head of the player like the x-axis of the camera in it, but i don't know how to do that. I know how to rotate single axes, but not how to rotate them like an other gameobjects axis.
Here`s my code, which doesn't work, because there it is rotating all the axes:
using UnityEngine;
using System.Collections;
public class Kopf : MonoBehaviour {
public GameObject MainCamera;
public GameObject Camera2;
void Update () {
if (MainCamera.activeInHierarchy)
{
transform.rotation = MainCamera.transform.rotation;
}
if(Camera2.activeInHierarchy)
{
transform.rotation = Camera2.transform.rotation;
}
}
}
↧