I need to have a little man run around the room. I wrote that if it approaches the border, then it should change the direction to the opposite. But sooner or later it leaves the room anyway. What am I doing wrong? How can a deliberate movement be realized?
Maybe you could rely on our mesh navigation system adding @Cedric for this part
Yes, you can rely on navigation. Documentation and PG here : Crowd agents - Babylon.js Documentation
You can also keep the physics running if you set the linear velocity as a vector (crowd agent position - impostor position) multiplied by a max speed.
But be careful if the physics is stuck at some point and the crowd agent keeps going. If that happens, when the distance between the crowd agent and the impostor is to big, then teleport the impostor at the agent position.
I read the article you pointed out. But I still don’t understand how to use this together with physics … Could you demonstrate a small demo?
P.S. Will there be a correct interaction of bodies moving along navigation and another body, which is also a physical object
In this PG, the purple box is the crowd agent (a box attached to the crowd agent actually) and the grey box is a physics impostor that follows the agent.
You can achieve that with just a call to setLinearVelocity. See lines 91-100