- Home /
how to lock rotation
i have been having problems with my 3rd person shooter script and it looking the direction that hte camera is looking, and i finally got the answers but it is not complete yet. this is my script that is attached to the player so it looks at a cube attached to the camera.
function Update()
{
var cube : Transform;
transform.LookAt(cube);
}
now that it works i only want my character to look around, not up and down because the gun will do that. so how would i do that?
Answer by Maarten · Mar 29, 2011 at 03:48 PM
You can just get the Y axis out of the lookat? So
transform.LookAt(new Vector3(cube.position.x,transform.position.y,cube.position.z));
Or something like that.
i got this error Assets/my scripts/walker.js(12,25): BCE0023: No appropriate version of 'UnityEngine.Transform.LookAt' for the argument list '(float, float, float)' was found.
Sorry it should be:
transform.LookAt(new Vector3(cube.position.x,transform.position.y,cube.position.z));
Your answer
Follow this Question
Related Questions
Controlling camera rotation limits. 1 Answer
What is asset Server client license? 2 Answers
Limit Screen Resolution 1 Answer
Limit player transform on x axis 1 Answer
Limit cameras near range ? 1 Answer