Hi all,
I’m currently busy with my charachter controller for my 2D game and like the smoothness from ‘velocity’ however i can’t seem to solve the slipping from the charachter. Is there a solution for this problem?
My code:
float moveH = Input.GetAxis("Horizontal");
float moveV = Input.GetAxis("Vertical");
if (moveH > 0)
{
rb2D.velocity = new Vector2(moveH * maxSpeed, rb2D.velocity.y);
}
else if (moveH < 0)
{
rb2D.velocity = new Vector2(moveH * maxSpeed, rb2D.velocity.y);
}
else
{
rb2D.velocity = new Vector2(0, rb2D.velocity.y);
}
if (moveV > 0)
{
rb2D.velocity = new Vector2(rb2D.velocity.x, moveV * maxSpeed);
}
else if (moveV < 0)
{
rb2D.velocity = new Vector2(rb2D.velocity.x, moveV * maxSpeed);
}
else
{
rb2D.velocity = new Vector2(rb2D.velocity.x, 0);
}
Debug.Log(moveH);
Debug.Log(moveV);
}
Kind regards,
Ruben