I have been trying to figure out what is wrong for a while now, but I am still completly clueless.
I am trying to get creature walk around randomly on a landscape. My problem is, that for some reason, all creatures always end up walking to one specific corner of the landscape, it is not apparent right away, but after a while all creatures is just in one corner… it is as if the random, is “more random” in a specific direction… its the same corner for all sessions, and it is the same for all creatures. If anyone know what is going on, please help me.
Here is the method
public void Wander ()
{
destination = transform.position + Random.onUnitSphere * wanderDistance;
destination.y = 100f;
Ray ray = new Ray(destination, Vector3.up*-1);
Physics.Raycast(ray, out hit);
if(hit.collider == null)
return;
if (hit.collider.gameObject.tag == "Terrain") {
destination.y = hit.point.y;
}
//tempObject.transform.position = destination;
navMeshAgent.SetDestination (destination);
isWalking = true;
}