Hi I’m working on my first game, a top down 2D game. I need the player to rotate smoothly 90 degrees around the local y axis over half a second. At the moment I am using
GameObject.Find("Player").transform.Rotate(Vector3(0, 90, 0));
which rotates the character fine, but instantly rather than smoothly over around half a second as I need it to. I have tried using Time.deltaTime but when used the character rotates a small amount rather than the full 90 degrees.
Here’s all I have so far
private var canMove : boolean;
function Start () {
canMove = true;
}
function Update () {
if(canMove){
if(Input.GetKeyDown("left")){
TurnLeft();
}
if(Input.GetKeyDown("right")){
TurnRight();
}
}
}
function TurnLeft () {
GameObject.Find("Player").transform.Rotate(Vector3(0, 90, 0));
}
function TurnRight () {
GameObject.Find("Player").transform.Rotate(Vector3(0, -90, 0));
}
This might be completely wrong but I am extremely new to coding still. Hope you can help.