getting the rotation of the included fps camera controller prefab

i would like to know how to get the rotation of the prefab so it sounds easy just use transform.rotation and it should return it but for some reason its just returning (0,0,0) like it has not turned when i look at the model in the editor its y has changed which is what i am interested in

using UnityEngine;
using System.Collections;

public class objectSpawn : MonoBehaviour {

    public GameObject gameObject = null;
    public GameObject rotationParent = null;
    // Update is called once per frame
    void Update() {
        if (Input.GetMouseButtonDown(0)) {
            RaycastHit hit;
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit))
                if (hit.collider.name != null)
                    Debug.Log("hit" + hit.point);
                    gameObject = Instantiate(Resources.Load("prefabs/prefabHouse"),hit.point,  rotationParent.transform.rotation) as GameObject;
                    Debug.Log(rotationParent.transform.rotation);
        }
    }
}

The rotation you see in the inspector is in Euler angles while transform.rotation return a Quaternion. Use this:

Debug.Log(rotationParent.transform.rotation.eulerAngles);
1 Like