- Home /
Reset position and direction
Hi there' In a First Person 3D world I want to have a reset key, so the position and rotation on the controller returns to it's original position and direction. I can get the position ok but how do I get the transform to face 0,0,0 ? Below is what I have so far..Thanks.
function Update () {
if (Input.GetKeyDown("6"))
{
transform.position = Vector3(0, 0, -4);
transform.localEulerAngles = new Vector3(0,0,0);
}
}
Answer by OrbitSoft · Dec 11, 2013 at 07:38 PM
transform.rotation = Quaternion.identity;
Wampir888, It doesn't seem to do anything. What I am trying to do is very simple. just point a game object at 0,0,0.
Answer by AlucardJay · Dec 11, 2013 at 08:49 PM
The answer by Wampir888 is the correct way to assign a rotation equivalent to a Vector3.forward
If you want the object to look at the origin (0,0,0), then use transform.LookAt
transform.LookAt( Vector3.zero );
or depending on your requirements
transform.LookAt( new Vector3(0,transform.position.y,0) );
Or you can go the long way around and calculate the rotation with Quaternion.LookRotation.
Your answer
![](https://koobas.hobune.stream/wayback/20220613123943im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Camera/Direction Rotation 2 Answers
Rotating a direction Vector3 by Quaternion 2 Answers
Shuriken particle trail rotating 1 Answer
How to move player in direction where the camera is aiming ? 1 Answer