How can I random move inside a Polygon?

Hi guys, can u give me a light about this concern?
Let’s suppose that I have several character models, and I want each model to move randomly within the specified range without colliding with each other. Can you give me some help?Is there any API method that can make this easy? Thanks for your time.

You are asking for game related features which are no part of a pure 3D engine. To implement your feature request, you need:

  • A random walk or “wander steering behavior” implementation.
  • Dynamic obstacle avoidance or non-penetration constraint (so game entities do not overlap)
  • Some sort of range restriction (meaning you want to keep the game entities in a specific area)

The Yuka project provides code examples for all of these use cases. I suggest you check out the example and showcase page for details.

1 Like

Thank you very much. This is a great library!

Does the Wander behavior work with NavMesh?

No it doesn’t. If you want to restrict the movement of entities, you have to implement checks by yourself.

Can you tell me how do I make characters rotate a bit naturally…everytime the entity finds a new region to go to it snaps towards the region direction.

do you mean using something like Quaternion.rotateTowards in an animation loop? otherwise you can use an animation engine like tween.js

https://mugen87.github.io/yuka/examples/navigation/navmeshPerformance/
I was going through this example. In this when a path ends and a new one is generated the entity snaps on to the path.