- Home /
How do you make collider interactions and movement smooth?
I am working on a top down game where I am building randomly generated rooms and using colliders for the walls. This is all well and good and is working fine. I am having problems with player movement & interaction with them.
If I use something like
if (Input.GetKey(moveUp))
{
rigidbody2D.velocity.y = speed;
}
for player movement then the player collides and stops and the interaction look fine but the player movement is jumpy.
If I modify this to something like
if (Input.GetKey(moveUp))
{
transform.Translate(Vector3.up * Time.deltaTime * speed);
}
Now player movement is smooth but when the player hits a collider they will tend to bounce against it if they keep pressing that direction.
If there a happy medium where I can get smooth movement for the player and have them stop against the colliders without the jitter?
Comment