Hello! I’m making a custom pathfinding system. Currently, I’m trying to get the npc to be able to go around walls but I have a problem, I have no idea how to get it to automatically find the corner that’s mirrored to the closest one to the player. Here’s a drawn example of what I mean because I’m bad at explaining:
this could help: Checking corners of a Part? - #7 by TOP_Crundee123
as far as identifying another wall, perhaps check the magnitudes of all nearby walls, sort and take the 2nd index of the table as the first index will be the closest wall?
I see the issue you present with mirroring, the only solution I could Imagine is ensuring that all walls are orientated equally & properly where
left wall’s topleft vector is == to right wall’s top left vector in terms of identifying corners
if you go with this method however, any wall that you rotate will make the system not work as intended
ex: We identify that the player is near top left corner, however we made a big mistake and rotated the right wall 180 degrees x axis so it is now flipped, fetching the topleft vector in respect to our pre-set operations, will net a differing position, where it is in view at the bottom right
or rather than doing that, you can just sort through a table of all the corners of a wall, obtain the closest corner in respect to the players position? negating the need to watch rotations
Will the NPC actively try to run away from the player? Is that its purpose?
You can get all the corners, assign a number to them (1-4) and use logic/math for determining the corner “normals”. You might have to use magnitude checking of these corner positions vs the player position (and possibly including the NPC position) to get the closest one.