Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Wierd RigidBody collisions in 2D

Discussion in 'Physics' started by fischerjo2506, Aug 8, 2023.

  1. fischerjo2506

    fischerjo2506

    Joined:
    Jul 13, 2023
    Posts:
    1
    I tried using the "Interpolate" setting on my rigidbody, but now the object simply ignores all collision. I dont know if that has to do with the way I am moving it (rigidbody.transform.Translate(moveDirection)) or with the collision in my tilemap (I use a tilemap collider combined with a composite collider, in the editor the collision-lines look fine). I am pretty new to Unity and probably miss something easy. Can anyone help?
    (You can see my Player Rigidbody and the tilemap in the attached files)
     

    Attached Files:

  2. Kechrimpari

    Kechrimpari

    Joined:
    Apr 5, 2022
    Posts:
    16
    Interpolate is supposed to smooth out jittery movement, so I don't know why that would affect your collision. What do your colliders look like?
     
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,778
    Interpolation has no effect on physics itself. It's purely a function of the Transform to move it from the last body pose to the current one; nothing more.

    This is just "transform.Translate()" (you can get the Transform from any component) and it isn't physics movement; it's bypassing physics completely and forcing the Rigidbody2D to read that position when the simulation next runs. Don't ever modify the Transform if you want to use physics because the whole point of a Rigidbody2D is to Write to the Transform.

    Always use the Rigidbody2D API to cause movement. Take a look at the scripting reference or follow one of the many tutorials showing you 2D physics movement.

    If you're doing this because of any tutorial then find another tutorial, it's never going to give you good results.