// takes in pos and target as 3D world coordinates public static Vector3 Flee(Vector3 position, Vector3 target, LevelInfo mapInfo) { // delegate/reduce to 2D data version Vector2 gridVersion = Flee(mapInfo.LevelToGrid(position), mapInfo.LevelToGrid(target), mapInfo); return mapInfo.GridToLevel(gridVersion); }
// takes in pos and target as 3D world coordinates public static Vector3 Find(Vector3 position, Vector3 target, LevelInfo mapInfo) { // optional todo: first perform a raycast from position to target // if there is nothing blocking // simply return target // Note: to do this properly, we'd need a layerMask as to not // "collide" with the player (meaning it'd always return false) // delegate/reduce to 2D data version Vector2 gridVersion = Find(mapInfo.LevelToGrid(position), mapInfo.LevelToGrid(target), mapInfo); return mapInfo.GridToLevel(gridVersion); }