I want to smoothly rotate the player when clicking LMB using this code
void Update()
{
if (Input.GetMouseButtonDown(0))
{
if (transform.rotation == Quaternion.identity) //if LMB and current Y degree equal to zero i move it to 90 degrees to left
{
transform.rotation *= Quaternion.AngleAxis(-90, Vector3.up);
}
else //if LMB and current Y degree equal to -90 (player moves left) i move it to 90 degrees to right (back to 0 world degree)
{
transform.rotation *= Quaternion.AngleAxis(90, Vector3.up);
}
}
transform.Translate(Vector3.forward * speed * Time.deltaTime); //running forward
}
If the rotation is smooth, it will take a lot longer - won’r your game break (the tiles behind start dropping fast) if the player takes more time to turn?
In any way, instead of turning your char by 90 degrees immediately, start a turn by setting a ‘turning’ and ‘targetRotation’ and then simply lerp. But again, this will take time and might brak your gameplay.
Tiles start falling after 1 second after player exits tile trigger collider. Can u help with code? I tried different variants such as:
Quaternion moveLeft = Quaternion.Euler(0, -90f, 0);
transform.rotation = Quaternion.Slerp(transform.rotation, moveLeft, .5f);
and
Quaternion.RotateTowads()
and it doesnt work