- Home /
how to tell what platform you're on.
If there are four connecting squares and the player is on top of them all but mostly over one how can I tell which square it is that the player is mostly on.
I was thinking of setting multiple rays under the player and setting which square had hit the most amount of rays and counting that but I was wondering if there was a more efficient way.
Thanks!
Logically, shouldn't it only require a single, centered raycast to deter$$anonymous$$e which square is most covered by the player?
If the shapes weren't square (such as triangles, with even more pronounced difference if not equilateral), or if the squares weren't consistent sizes, it would be a different matter, since a tiny square could have the smallest surface area covered, despite being centered under the player.
If they're all the same size squares, however, whichever one a centered raycast hits is the only one that can be covered most by the player, assu$$anonymous$$g the squares aren't overlapping.
Answer by tanoshimi · Jun 28, 2015 at 08:34 AM
Is it not just the case of comparing the distance from the centre of the player to the centre of each square? The square that is closest is the one you are "mostly" on.
I used array find closest game object and that worked great.
Your answer
![](https://koobas.hobune.stream/wayback/20220613201449im_/https://answers.unity.com/themes/thub/images/avi.jpg)