# algorythm to detect nearest edge on object from players

This topic is 824 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I frequent things like unreal, and unity.

I have this problem that i need to solve,

in which a character, standing near either a vertical plane or a small railing, which supposed to part of the arena,

will detect edges/planes nearest to it.

The character does not need to be facing these points of interest,

as long as they are within a certain proximity to it.

the priority is of course, the character's angle of view.

My problem so far is because vertical plane is part of larger structure, an arch or maybe a giant rocks with girdles on it.
Or since the railing is a long piece of surface, it is hard to take the nearest point on the edge of the railing to be marked.
Either i am thinking it wrong, or there's a formula to solve this.

I hope to discuss this rather than a straight answer.

##### Share on other sites

I am assuming that you want to detect the vertical planes around your arena for collision detection? If not can you give me some more details?

If so normally, you will find this in Unreal and Unity, you will create a collision mesh around your object (rock, chair etc.) that is a lot simple in complexity compared to the object within it. For example, the collision mesh could be a cube but the object within it is a chair. This is because it is simpler and easier to test for a collision vs the simple collision mesh then the object mesh.

As for which one of these meshes is closest to your character, you could do this a number of ways. The most straightforward, but by far not the most efficient, is to test if there has been a collision between each mesh vs the character (just a for loop). You could extend this to a radius around your character too, get a vector length between your character and the target object. For improved methods to do this, you could do a K-D Tree/Octree for example but this would require more work to get set up but on the long run would a way to go.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 15
• 14
• 46
• ### Forum Statistics

• Total Topics
634057
• Total Posts
3015283
×