I am Working on RPG I am stuck on Few things
1.At the time of map loading All all enemy spawn point are received from the server. What I want to find the given vector3 position is walkable or not, if not will not spawn anything or walkable it will. How i can do that
- so the town map will be having 2 zones non-hunting area and hunting area
Player will be able to move all the map but the Monsters / NPC can only walk in a specified area(Hunting area) as they will not be allowed to enter the town??
Can this be achieved with navmesh ??
You can use a Navmesh hit to check if the area is considered Walkable by your navmesh.
NavMeshHit navMeshHit;
if(NavMesh.SamplePosition(enemySpawnPosition, out navMeshHit, 0.1f, NavMesh.AllAreas)) {
if (navMeshHit.mask == 0)
{
// Walkable terrain
}
}
Obviously you wont want just “walkable” terrain, but you can create your own navmesh mask. Alternatively, and probably more efficient, you can use a Bounds and place it around you town, then check this.
public Bounds townBounds;
if (!townBounds.Contains(enemySpawnPosition))
{
// Safe to spawn enemies here
}