Hey, I’m having lots of trouble with a seemingly simple problem.
I’m using LookAt() method then setting the axes I don’t want to move back to 0 with:
aim.rotation= Quaternion.Euler(new Vector3(0,aim.rotation.y,0));
However, the value of aim.rotation.y changes when I do this and I can’t figure out why or how to get around it.
Also, I’m not quite certain how I should be using the LookAt method. I have imported my model from blender so it is currently on z-up local co-ordinates, should I be passing in a different world up vector?
In a different case I managed to get a similar thing working, but I don’t understand why it worked. I was currently trying to get something to pan, so I wanted only its y rotation to change, so to do this (after previous method didn’t work) I did this:
aimP.LookAt(new Vector3(target.position.x,aimP.y,target.position.z));
That would make sense to me, since it would be aiming at something at its own height (which was about 0.3 btw) and as such it would not have to tilt to face it. However this didn’t work and it was only when I passed in an arbitrary number (90) that it worked. I tested it with some other numbers and it seemed to tilt up and up from 0 to about 13, where it locked and was straight how I wanted it.
So yeah, I’m very confused about all of this and I hope someone can help me out. Thanks.
Working with c# btw.