Choose random point within an angular field of view
I am trying to create a more realistic way to move my agents around the map. I have set them to move to a randomly chosen point on the navmesh. When the agent reaches that randompoint, the random point is recalculated and so forth.
How would I be able to create the random point chosen to be within a 90 degree field of view, based on the current forward direction of the agent. This would mean that direction change of agents is not too drastic.
The current random point is calculated as follows:
Vector3 randomDestinations = new Vector3(Random.insideUnitSphere.x * 200, transform.position.y, Random.insideUnitSphere.z * 200);
randomDestinations += boids.transform.position;
NavMeshHit hit;
NavMesh.SamplePosition(randomDestinations, out hit, 200, 1);
randomDestination = hit.position;
Your answer
Follow this Question
Related Questions
Basic MOVE and JUMP script (Jump trouble) 2 Answers
C# Unity Move the player along a* found path 0 Answers
need help in obstacle avoidance math 2 Answers
Bug on Character movement 0 Answers
Unity NavMesh path-finding with my own moment script. 1 Answer