Hi,
Today I tried to implement the Local Avoidance in my WIP game and there is one small issue - there is something like a flicker when the enemies are moving around. I tried drawing a ray for each enemy’s actual move speed and I’m seeing big spikes.
I read the docs. I made an empty GameObject to hold the RVOController, put it in a RVO layer and everything else that belongs to the enemy is a child of that object. The children are not on the same layer. Then, in RVOController’s options I set only the RVO layer as a mask, like the docs say.
However if I use just cylinders instead of my enemies it works fine, so it must have something to do with the masks and colliders that the enemies have. Seems like the mask property doesn’t work for children maybe?
P.S. You can’t really see the effect in the game window because of the low fps of the screencast, but it’s very noticeable live.
P.S.#2 Here is how I’m moving the enemies:
Try turning on interpolation on the RVOSimulator component.
Also a higher simulation fps can help.
The local avoidance system does not calculate the velocities and positions every frame for performance. If not using interpolation, the characters will move forwards only some frames, when using interpolation, it will try to fake movement during those frames it does not do any (heavy) calculations.
In the simulator options interpolation is on, as is double buffering and the fps is at 30. I’m also noticing big drop in fps when enemies are bunched together on my iPad 3.
I still think this comes from the different colliders that I have on my enemies. Are you sure they can’t be causing the issue?
Try to avoid colliders, you generally want to avoid the physics system interfering. You can keep them as triggers though.
Hm, I really hope you attached rigidbodies to them if you had colliders. Moving a static collider is really slow and could cause FPS spikes.
You can try turning of double buffering, if there is a large variation in FPS, then that might cause the movement to not look as smooth.
If you see drops in FPS when they are bundled together, you can try adjusting the Max Neighbours on the agent and the horizons. Lower values will give you a lower quality local avoidance, but it will be faster.
Keeping the colliders as triggers doesn’t work for me because the player doesn’t collide with the enemies. I did put all enemies on a layer and excluded physics between objects on that layer and now I don’t get FPS drops when enemies are bunched together.
I also tried adding a kinematic rigidbody to all enemies - I can’t measure any difference but if you say it’s better with rigidbodies I will keep them.
Still can’t fix those damn spikes. They occur even when I build & run on my laptop.
It gets really bad if I select an agent in the editor. I don’t know, I’m out of ideas.
I tried making a blank project with 300 cylinders and it runs fine, so the problem can’t be coming from the simulation. I tried deleting all colliders, no effect. I removed the shadow projectors - seems a little bit better, but the problem is still there.
I have no idea either… sorry… : (
Try recreating it from the cylinders, adding components and scripts til you find what makes the difference betweeen smooth and spiky.
I have noticed the same issue today on my project, and seems to be related to friction with the surface below the AI. If I remove the physics material from it, it seems to get rid of the hiccups in the movement. Would have to be confirmed, maybe it’s a coincidence, but I’d assume it’s as Aron said: physics interfering with the interpolation.
I’m not using any physics material for the ground (unfortunately). I’m having some doubts that the issue might be coming from the fact that I have 100 skinned and animated meshes running independently and it’s just CPU overhead that is making the simulation skip frames or something.
I just noticed the other day that I have about 400 draw calls for 100 characters and something is very wrong, and it was - I had an extra light in the scene. I removed it, the draw calls are a bit over 100 and it’s MUCH better now.
I also watched a demo from the Unite 2013 keynote where they show 2000 skinned and animated moving characters and it was running on 60+ fps. Don’t know on what machine, though. I will try to port my animations to Mecanim, because they are legacy right now, and take advantage of Mecanim’s bone optimization feature, which would reduce the number of GameObjects I have in my scene dramatically and it must improve the fps. Combine that with the fact that Mecanim is much more optimized than the legacy system (can someone confirm that?) and I should be good to go.
My conclusion is that it’s just general CPU overhead coming from many places in my scene, and not just the RVO simulation, so optimization should be the fix here. I’ll post updates!