I try to make my player model rotate with camera movement but only on Y axis like in almost every other game. The thing is I can only rotate it along all axis because if I try to assign camera Y rotation to player Y rotation, Unity throws out errors about float/quaterion conversion. How to do it?
@Gracek
Not the prettiest, but this should do it for you I think?
using UnityEngine;
using System.Collections;
public class playerRotator : MonoBehaviour {
public GameObject kamera; // Assign the object that spins in x,y,z
public Quaternion rotacja = Quaternion.identity;
void LateUpdate () {
rotacja.eulerAngles = new Vector3 (transform.rotation.eulerAngles.x, kamera.transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.x);
transform.rotation = rotacja;
}
}