Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Player - Rigidbody2D Kinematic. How can Collider stop him?

Discussion in 'Physics' started by arturiklive, Mar 1, 2024.

  1. arturiklive

    arturiklive

    Joined:
    Feb 21, 2021
    Posts:
    1
    Hi!
    I am creating 2d game. Player needs to be with Rigidbody2D Kinematic. So, he can go through all walls.
    I need to create map borders. How should I do this? Player ignores all empty objects with collider and rigidbody2D..

    Layer Collision Matrix all checked.

     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,589
    The whole point of a Kinematic Rigidbody2D is that it doesn't reaction to collisions, gravity, user-forces etc. In short, it doesn't have a collision response and you move it using MovePosition/MoveRotation.

    It's up to you to stop it moving outside of the region you define using whatever method you choose such as checking its position within the rectangular game region or using physics queries to check if it can move before asking it to move.

    This sounds like you're not understanding what a Kinematic Rigidbody2D does but if that's not the case then maybe you can explain some more about what's not working.