Search Unity

Sprite getting stuck in Platforms and Become Unmovable

Discussion in '2D' started by cottonbloom, Feb 14, 2019.

  1. cottonbloom

    cottonbloom

    Joined:
    Dec 18, 2018
    Posts:
    16
    I'm working in Unity 2018.1, working on a 2D platformer prototype and I for the life of me can't seem to figure out why my character sprite keeps getting stuck in floors after falling from a distance. It could be a RigidBody2D gravity scale issue, though the character is meant to have gravity when falling, and when changing numbers in the RigidBody, it either makes the character unable to move or jump infinitely.

    If you'd like to know what the character controller script I'm using is, it's the same character controller scripts from Brackey's 2D sprite movement tutorials. Both the CharacterController and PlayerMovement are from his videos (in fact, I suspect his character controller could also be the root of the issue... though I'm a beginner programmer so I'm not sure where I can find the root of that problem if it exists).

    I have a box collider and composite collider 2D on the tilemaps, as well as a Circle and Box collider on the character sprite, which is coupled with a Dynamic Rigidbody2D with a gravity scale of 3 and mass of 1. The player sprite also has a ground check and ceiling check respectively.

    If anyone has alternative character controllers, or different solutions to the platform problem, please let me know! I'm still experimenting but I'm open to different methods. TO NOTE: I have already tried using Edge Colliders, both on the character and on the platforms, but the same issue occurs. I also have a "slippery" 2D physics material on both the character and platforms.
     
  2. Geejayz

    Geejayz

    Joined:
    Feb 8, 2016
    Posts:
    73
    Hi Cottonbloom,
    One thing you could try, on your Rigidbody2D of your character, set the collision detection to 'Continious' rather than 'Discrete'. I am wondering if perhaps the rate your player is falling means the collision is being missed.
     
  3. cottonbloom

    cottonbloom

    Joined:
    Dec 18, 2018
    Posts:
    16
    That seems to work! It also appears to be an issue with the platform's colliders being 'Outlines' rather than 'Polygons'. The two combined seem to help the player move up slopes more efficiently as well. I'm going to do some further testing, but this seems to work! Thankyou :D