Hello, I want to achieve this perfect car drift (rotation) like they did in Sling Drift. My player is always moving in the forward direction.
I want the player to rotate the same amount as the curve.
currently, I’m just using simple rotation.
[Header("Player Settings")]
[SerializeField] float moveSpeed = 2f;
[SerializeField] float rotateAmount = 1f;
Rigidbody2D rb;
private void Start()
{
rb = GetComponent<Rigidbody2D>();
}
private void Update()
{
MoveForward();
HandleDrift();
}
private void HandleDrift()
{
if (Input.GetMouseButton(0))
{
transform.Rotate(new Vector3(0,0,rotateAmount*Time.deltaTime));
}
}
private void MoveForward()
{
transform.position += transform.up * moveSpeed * Time.deltaTime;
}