Question by
SunilUL · Feb 17, 2017 at 10:02 PM ·
rotationscenequaternionruntimefirst person controller
First Person Controller Camera doesn't rotate in runtime
#pragma strict
private var FPS : GameObject;
function Start () {
FPS = GameObject.Find("FPSController");
}
function Update () {
if (Input.GetMouseButtonDown(0)) {
var buttonName = EventSystems.EventSystem.current.currentSelectedGameObject.name;
var VP : GameObject = GameObject.Find(buttonName); // VP = View Point
Debug.Log("VP Rotation = " + VP.transform.eulerAngles);
FPS.transform.localPosition = VP.transform.localPosition;
FPS.transform.eulerAngles = VP.transform.eulerAngles;
Debug.Log("FPS Rotation = " + FPS.transform.eulerAngles);
//FPS.transform.localScale = VP.transform.localScale;
}
}
The Above is the code i've written to move camera from one place to another. The position works perfectly.
Even rotation works, but as soon as the camera is rotated, within fraction of secs, it gets reset to 0,0,0;
FPS doesn't even rotate when tried rotating camera through scene window in run-time.
Can anyone help me to achieve this?
Thanks.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612111241im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Using a directional vector to orient a sphere? 0 Answers
Rotate around a point with a specific angle 0 Answers
How to make camera moving as the player on a planet 0 Answers
2D TopDown rotating a gun according to its parent position, ON MOBILE, not PC, 0 Answers
Rotate plane in relation to camera 0 Answers