- Home /
How Can i Make Fps Controller Rotate and face a target.
Hey guys I'm developing my first game so am a bit new to Unity, so my problem is am trying to rotate the Fps Controller to face a target by the push of a button. I managed to rotate the camera alone by attaching this code to it but only the camera rotates so it completely messes up the walking.
public class PlayerRotate : MonoBehaviour {
public Transform target;
void Update(){
if(Input.GetKeyDown("r")){
print ("Rotate");
transform.LookAt(target.position);
}
}
}
I also tried attaching the same script to the Fps Controller but nothing happens. Anyone's help would be greatly appreciated, Thanks
Your answer
Follow this Question
Related Questions
How to catch a rotation from transform.LookAt function? 0 Answers
Creating a homing missile on 2D, problem with transform.lookat() 1 Answer
Keep the scene view rotation of my camera in play mode (it resets to 0) [EXAM ^^] 1 Answer
FPS Controller rotation,FPS Controller rotation problem 0 Answers
How do you make a Raycast follow your mouse in an FPS? 0 Answers