- Home /
rotate spine acording to camera
ok im using the default character controller with the 2 mouse looks how do i get the spine bone to rotate on the x axis according to the angle of the camera up and down? also would this interfere with animations? here is what i have tried but it dosent work is their something i am doing wrong?
using UnityEngine;
using System.Collections;
public class aimupanddown : MonoBehaviour {
public Transform spineBone;
// Use this for initialization
void Start () {
spineBone = GetComponentsInChildren("spine");
}
// Update is called once per frame
void Update () {
float xRot = Camera.main.transform.localEulerAngles.x;
spineBone.transform.localEulerAngles = new Vector3(xRot,0,0);
}
}
Comment
Just parent the Camera to the SpineBone.
Else you could do
float xRot = spineBone.transform.localEulerAngles.x;
Camera.main.transform.localEulerAngles = new Vector(xRot,y,z);
what would be the best function for this? update? or lateupdate?
using UnityEngine;
using System.Collections;
public class aimupanddown : $$anonymous$$onoBehaviour {
public GameObject spineBone;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
float xRot = spineBone.transform.localEulerAngles.x;
Camera.main.transform.localEulerAngles = new Vector(xRot,y,z);
}
}
error: The type or namespace name `Vector' could not be found. Are you missing a using directive or an assembly reference?
Answer by androids · Apr 20, 2015 at 01:49 PM
How did you solved this problem, because I have the same problem here.