23.08.2018, 18:11
Quote:
What TheBlackHand suggested is only a small step you have to do. It just gets the coords in front of the NPC.
What you need to do is raycast between the NPC and the destination (using CA_RayCastLine) repeatedly while moving. If a collision is found however you need to find a new direction that is possible to reach. Also a single RayCast is not sufficient, as the feet, torso and/or head can be blocked, or the RayCast hits a small hole in an otherwise big object. Then you also want to check if there is actually ground to walk on and how high it is. Raycast straight down from in front of the NPC and check if there is a surface to walk on. It's not as simple as raycasting once or twice to make it perfect. There are small objects that can be missed easily and then the NPC will just ignore these objects or get stuck inside of them. Without pathfinder it's a good idea to raycast different directions and find suitable ones, then find the one that gets the NPC closest to the destination but again, without pathfinding it's hard to traverse complex maps. |