Search Unity

Whats the best way to detect the floors Y position below character?

Discussion in 'Scripting' started by Epic-Username, Jul 29, 2015.

  1. Epic-Username

    Epic-Username

    Joined:
    May 24, 2015
    Posts:
    339
    I have though of ray-casting but i don't think its efficient having ray-casting for all of the players all over the place, i have also thought of creating a sensor object to detect floor but the floor isn't a separate part, its part of a big object.
    So whats the most efficient or most common way of detecting floor?

    Thanks.
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Raycasting is most commonly used. Its a fairly generic solution.

    Alternatively you can read the height directly from your terrain. This solution will vary depending on the exact implementation of your scene. But if you have supreme commander numbers of units around it can be worth the effort.
     
  3. Epic-Username

    Epic-Username

    Joined:
    May 24, 2015
    Posts:
    339
    I know how to create ray-casts and get game objects through them but how to i detect which Y position it hits.
     
  4. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201