I have player Y rotation on joystick input working, but I am trying to figure out how to make it happen smoothly- right now the player snaps to the rotation angle I want. if anyone could help me, I would appreciate it.
// Move/rotate Player
if (count == 0) { //we are behind the player
float rotation = 0.0f;
float pyTarget = Input.GetAxis (Stick + " Stick Horizontal") * targetAngle;
float pxTarget = Input.GetAxis (Stick + " Stick Horizontal") * targetAngle;
rotation += pyTarget; //add joystick movement to player rotation
var playerMove = new Vector3 (pxTarget, 0, 0); //set X movement to stick input
Player.transform.eulerAngles = new Vector3 (0, rotation, 0); //rotate the player in direction of stick
Player.transform.position += (playerMove * (Time.deltaTime/damp)); //move player in direction of stick
Vector3 PlayerPos = Player.transform.position; //store player position
// bind player to center area of screen
if (Player.transform.position.x <= -6.4f) {
PlayerPos.x = -6.4f;
}
if (Player.transform.position.x >= -3.4) {
PlayerPos.x = -3.4f;
}
PlayerPos.z = -5.5f;// lock Z axis to prevent drift
Player.transform.position = PlayerPos;
}