Search Unity

Custom Gravity ground/surface checking (help)

Discussion in 'Physics' started by Dorscherl, Dec 26, 2018.

  1. Dorscherl

    Dorscherl

    Joined:
    May 29, 2017
    Posts:
    26
    I am working on creating a gravity system where it can be changed at a moment's notice. I made a script that successfully changed the gravity direction on an individual object and which even rotated the character to land on its feet.
    However, my biggest thing is trying to find a way where the player will fall with gravity, hit the surface, and then try to stand up.
    I need a way to check for the ground in accordance with freeform gravity. I normally use raycast to check the ground but I don't see that being a good way if the player is on his back.

    Sorry if this in the wrong discussion
     
  2. Why? You wouldn't raycast towards the feet, you would raycast towards gravity direction.
     
  3. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    Or just maybe check the rotation on the player's object to see if it's upright / what ever else?
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,775
    From player's center of mass, you can raycast, toward gravity source, or player's velocity direction and check for surface hit.

    Just thoughts.
     
    xVergilx likes this.