(RichAI) agents are teleported to wrong locations

Hey! I currently have problems with my AIAgents sometimes getting teleported to wrong positions (under the surface of the game world). My manual positioning (when I spawn the agents) isworking fine and the agents get set to the correct locations (random positions on the navMesh). But in the RVOController’s Update function you do this:

if (lastPosition != tr.position) { Teleport (tr.position); }

“lastPosition” is the position I set by manually calling the Teleport function (rvoController.Teleport(pos);). In there “tr.position” gets set to “pos” aswell. But in Update “tr.position” does not equal “lastPosition”. “tr.Position” apparently gets changed somewhere else but I can’t figure out where. Somewhere in the RVOSimulation?

Besides the RVOController the agents have a richAI component attached to them as well and I am using a recastGraph.

Cheers,
Thomas

Hi

That might be a bug somewhere.
Would it be possible for you to throw together a small example project which shows the issue? That would be very helpful for me so that I can track down the bug.

In the meantime, try disabling “Double Buffering” on the rvo simulator if it was enabled, that is the most likely thing to cause that kind of trouble I think.

Disabling “Double Buffering” didn’t do the trick. I will try to set up a small example project. But I don’t now if I can find the time before the weekend.

Update: When I disable the RVOController on my AIs they still are placed at wrong positions. Because the RVOController doesn’t raycast for the ground anymore they now are not only positioned under the surface but sometimes are walking in mid air.

Apparently all this behaviour has something to do with the RichAI script. I disabled it on my agents and added the AIPath script to them. They are now getting placed correctly and don’t get teleported away anymore.
But of course the calculated paths are not as nice as the RichAI paths and the wall avoidance was pretty cool as well. So it would be nice to get that working again.

I also had the problem on terrain.
I set center Y = 0 in RVOcontroller. It fixed the bug.

Interesting. Maybe that helps Aron fix the bug.
For me the solution was to tweek the OnDisable function in the RichAI script. Since I am using an object pool for my AI agents I constantly disable and enable some of them. The gloabl RichPath variable rp in the RichAI script is not cleared when an agent gets disabled. Apparently that is the problem. When I set “rp” to null in the OnDisable (and also stop the coroutine “SearchPaths”) everything is working fine. The agents are spawned at the correct locations and don’t get teleported away to wrong positions.

I would flag this thread as answered but apparently I can’t do that with my own post.

Hi,
To avoid that the object teleport to grid, try chane line 300 of RVOController to: if (mask != 0 && Physics.Raycast (realPos + Vector3.up * 10000 * height * 0.5f, Vector3.down, out hit, float.PositiveInfinity, mask))… Then mask to terrain for example. It may help. Sorry for my english.