Hejsa!
I am trying to rotate a object along with a transform(camera) when the player moves, but unfortunately it only works between a specific rotation.
The script:(A simple test for a much larger script, because I noticed there were some issues.)
var GameCam : Transform;
function Update ()
{
if(Input.GetAxis("Vertical") || Input.GetAxis("Horizontal"))
{
transform.rotation.y = GameCam.rotation.y;
}
transform.Translate(Input.GetAxis("Horizontal")/20, 0 , Input.GetAxis("Vertical")/20);
}
What the script is supposed to do is to rotate the object the script is attached too, to align it self with the camera when the player moves using the horizontal and vertical axis like a 3 person shooter, which works fine, but only between a certain rotation( 150 - 200) and if the object is out of that rotation the rotations “fucks up” so too speak.
I have read that I should use Quaternions, but I have really no experience with them nor do I know how to get a solution out of them.
If you have a solution to this matter I would really appreciate the help.
Regards.