Search Unity

Best method for checking if player is grounded?

Discussion in '2D' started by TumbaBit, Apr 11, 2014.

  1. TumbaBit

    TumbaBit

    Joined:
    Feb 17, 2013
    Posts:
    9
    First of all, I'm terribly sorry if this is in the wrong section, I didn't know if the 2D section was only for resources and such and not for scripting.

    I'm making a small platform with weird stuff like changing gravity and such, and I'm wondering what the best method for checking if a player is grounded, is. I know of the onCollisionEnter and the linecast method, but I was wondering if there was any other method better suited? A javascript snippet with a standard if/else that sets the grounded variable, would be greatly appreciated, whatever the best method is. Thank you very much.