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. Dismiss Notice

Question Player gets stuck on platforms

Discussion in 'Physics' started by karelhladky, Sep 9, 2023.

  1. karelhladky

    karelhladky

    Joined:
    Apr 6, 2014
    Posts:
    9
    Hi guys,

    I need help! I have player (simple cube with rigidbody and box collider) that is moving on platforms (again simple cubes with box colliders) and sometimes player gets stuck when is between those platforms. Here is video


    I'm using AddForce for moving player and I've tried all types of Collision Detection in rigidbody component. Settings of Rigidbody component:

    Snímek obrazovky 2023-09-09 v 10.56.00.png


    Thanks!
    Karel
     
  2. Sooly123

    Sooly123

    Joined:
    Aug 24, 2022
    Posts:
    88
    Well, you say that the platforms are made of multiple cubes. That is bad for 2 reasons:
    1) as your game gets larger and larger, you game will get more and more objects. You want to have minimal Gameobjects as possible.
    2) the answer to your actual question, Unity is not going to perfectly actuate. Meaning that your cube will get caught in between the slight gaps (and I mean slight, it's like 0.0001f).

    So make a system to combine the colliders or something like that

    An example of this is Teardown. Every time you shoot an object you split the colliders and turn it into 2 objects.
     
    Last edited: Sep 13, 2023
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,468
  4. Sooly123

    Sooly123

    Joined:
    Aug 24, 2022
    Posts:
    88
    For a temporary fix, you can use a sphere collider or a capsule collider to smoothen it
     
  5. karelhladky

    karelhladky

    Joined:
    Apr 6, 2014
    Posts:
    9
    Well, one solution is to enable constraint for Y position, but then of course gravity doesn't affect my game object, so I could check "ground" game objects around (I'm already doing it) and toggle the constraint.

    Anyway thanks for your help