2.5D Shooter Upper Body Rotate to Mouse Problem
Hello, I have code for rotating my character to the mouse and I'm trying to get the code to just affect the upper body on my character. I have looked all around on the answers forum and the couple solutions I found do not work. First of all I tried dragging this script file onto the spine of my character, but it will not affect it at all. People have said to parent the upper body to a gameobject, but if I do that it breaks all animation on the upper body of my character. .
My model is set up like this. If I grab the rotate on the spine it rotates how I would want it to, but I can't get the code to affect it if I drag and drop it on the spine. I have tried to refer to this object in the code but then objectname.transform.LookAt(v3T) will not work unless the object referenced is a gameobject.
Any suggestions would be greatly appreciated I've been banging my head on this for a week now
void Update() {
if (Input.GetMouseButton (0))
RotateToMouse ();
}
void RotateToMouse() {
Vector3 v3T = Input.mousePosition;
v3T.z = Mathf.Abs(Camera.main.transform.position.z - transform.position.z);
v3T = Camera.main.ScreenToWorldPoint(v3T);
transform.LookAt(v3T);
}
}