Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

2D is on ground check providing false positives

Discussion in 'Physics' started by CJ-Clark, Nov 3, 2018.

  1. CJ-Clark

    CJ-Clark

    Joined:
    Jun 26, 2013
    Posts:
    2
    Hello, I'm writing a simple Mario-like game using RigidBodies. I'm struggling to properly detect if I am on the ground, due to floating point inaccuracy. Does anyone have ideas based on the below information? If so, thank you, it's been years of various approaches to this, none have yet worked.

    When the player stands against a ledge and jumps up past it and falls, they fall and hit the ground properly. I have a function that checks under the player to see if they are on the ground, it does a shape cast down using the same box on the player as a bounds. While falling, Unity shows no intersection via OnCollisionEnter, however my function to see if they are on the ground hits the ledge due to floating point inaccuracies.

    Another issue that's related, if I jump and tap towards the ledge so I would land a couple pixels on the ledge, Unity pushes me off the ledge as the collision resolution instead of resolving the collision with me landing ON the ledge like I should. All tunings in PhysicsManager and the RigidBody's don't seem to affect this at all.

    Here's my original post for more information and a picture.
    https://answers.unity.com/questions/1566479/2d-isonground-check-providing-false-positives.html