Search Unity

Smooth Colliding 2D

Discussion in 'Physics' started by Grafer, May 30, 2015.

  1. Grafer

    Grafer

    Joined:
    May 30, 2015
    Posts:
    18
    Hi!

    At first I'd like to mention that I'm beginner and I've look for an answer for my question but I couldn't fint it anywhere.

    So, the problem is presented on video below. I'd like to make collisions more smooth. You can see that character forces itself into the wall which occurs in weird "bouncing" animation.



    I use edge collider on the walls and box collider + RigidBody2D on character.

    Walls


    Character


    Is there anyway to make it "still", that when character meets wall he just stands here or at least make this animation less visible?
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    1,968
    I presume you're setting the Transform position directly? If so, that updates the Rigidbody2D position i.e. transports the rigid-body to the position you set and can be overlapping one of your walls. When the physics system updates, it solves the overlap by moving the rigid-body away.

    This is why you should not set the position directly on transform. Move it by calling MovePosition(), adding forces or setting the linear velocity on the rigid-body.