RVOController stops moving when scrolling in game

I’m having some strange behavior with the RVOController (using the AIPath script) and I’m not sure what’s causing it. It’s not happening when I switch my characters to use a CharacterController, so it must be the RVOController. Basically whenever I scroll our gameboard, the RVOController characters stop moving until I stop scrolling. I don’t see any obvious thing that would be causing it so I’m not sure how to proceed with fixing it. Any suggestions?

Along with that, I’m also seeing a weird behavior where my characters wobble when using the RVOController (again, with the AIPath script). What I mean by that is they seem to get stuck rotating left and right as they follow a path and end up sort of wobbling/zig zagging rather than walking a straight line. I’ve turned their rotation speed down to 2 and that seemed to fix things a little bit, but there’s still a noticeable wobble at times. Is there any other tuning I should look at to fix this? It’s another thing that I’m not seeing at all when I switch to using the CharacterController, so it must be something in the local avoidance doing it.

So wobbling issue seems to get better if I use a reasonably slow turn speed (2.5-ish in this case) and turn off the funnel modifier. The issue with our gameboard scrolling however seems to be more complicated. Basically, our characters and our world are parented under an object that we move around (rather than moving the camera) and the RVO controller (and likely also the simulator) doesn’t seem to like that. Is there going to be any way we can fix this issue so that the characters can be moved around like that without stopping them from moving?

Also, it’s very easy for me to trigger an IndexOutOfBounds exception in RVOAgent.cs, line 655. I’m not sure at all what’s causing it beyond having a single agent trying to find a path, but it’s not consistent about it.

Hi

Sorry for the late answer.
I am not quite sure what is happening. What ‘desired simulation fps’ are you using on the simulator component?
Try increasing it if it is very low.

Regarding the IndexOutOfBounds exception. do you think you could post the line which throws that exception? The line numbers differ between versions so it is hard to know which line it is by just using the line number.

How are you scrolling the game? Are you moving the whole world? If so, if I remember correctly the RVOController has some code that detects when it is being moved by an external script and disabled local avoidance when that happens (since the local avoidance happens in global space, it would be hard for it to keep track of the movement). I would suggest that instead of moving the whole world, you instead just move the camera.

I think for now the wobbling is more or less corrected for. I’ve bumped the simulation from 10 to 20 fps while lowering the rotation speed I was using and set up all of our walls as RVO obstacles. I’ll keep an eye on it, however.

So this is the section of code that’s throwing the IndexOutOfBounds exception in RVOAgent.cs:

} else if (signedDist > 0) {
    //Debug.DrawLine (position, (vertex.position+vertex.next.position)*0.5f, Color.yellow);
    Vector2 p1 = new Vector2(vertex.position.x, vertex.position.z) - position2D;
    Vector2 p2 = new Vector2(vertex.next.position.x, vertex.next.position.z) - position2D;
    Vector2 tang1 = (p1).normalized;
    Vector2 tang2 = (p2).normalized;
    vos[voCount] = new VO(position2D, p1, p2, tang1, tang2, wallWeight);
    voCount++;
}

And it is specifically this line in that block that’s doing it:

    vos[voCount] = new VO(position2D, p1, p2, tang1, tang2, wallWeight);

I wish I had more info to give on that one, I have several objects in the scene with RVOControllers that go active and inactive over time, I’m using Behavior Designer to control them, and I have RVO obstacles on my walls to help keep my characters from shoving through them. If there’s anything else I can send your way to help with that one, let me know.

Unfortunately, I’m not able to make the decision to move the camera instead of the world. I wish I could, because doing it this way has caused me a lot of headaches, but it’s basically out of my hands. I’ve dug into the code that you’re talking about, where it disables avoidance and teleports the controller objects around when they move externally and don’t see any obvious answers. It looks like there may not be a solution to this issue. Does that sound about right?

Is there any update of note regarding the IndexOutOfBoundsException that I’ve run into? I found another case of it in the same file shortly after the first occurrence:

				vos[voCount] = new VO(voBoundingOrigin, voCenter, totalRadius, relativeVelocity, inverseAgentTimeHorizon, 1);
				voCount++;
				if (DebugDraw) DrawVO(position2D + voBoundingOrigin*inverseAgentTimeHorizon + voCenter, totalRadius*inverseAgentTimeHorizon, position2D + voCenter);

I’ve also had to modify the AIPath OnEnable() to correct it repathing when it shouldn’t after being disabled and then enabled (which causes a lot of Cancelled path spam in the log):

protected IEnumerator RepeatTrySearchPath () {
	while (true) {
		while(!seeker.Is Done()) {
			yield return new WaitForSeconds(repathRate);
		}

		float v = TrySearchPath();

		yield return new WaitForSeconds(v);
	}
}

Does that change look like it the correct way to handle that?

Hi

I have not been able to replicate the IndexOutOfBoundsException. Can you replicate the bug easily? If so, would it be possible for you to send me a stripped down test scene in which I can debug it?

I honestly can’t get it to replicate outside of our project either. We have completely dynamic creation of our scene’s GameObjects and so both our RVOObstacles and our RVOControllers/RVOSimulator are added to the scene in a way that’s somewhat difficult to put into a separate project. I was thinking it might be a threading issue, but it still shows up even when the RVO worker threads is set to None. If it helps, I have it printing out some debug info:

prevented obstacle index out of bounds exception - vos: 82, voCount: 82 simulator obstacles: 81

So in this case, from the simulator.obstacles loop, the voCount has gone one beyond the number of obstacles and gone beyond the number of vos.

prevented neighbor index out of bounds exception - vos: 82, voCount: 82 neighbors: 1

And in this case we’ve already gone beyond the number of vos, so the neighbors loop is already thrown off.

Is there any other info that I could pull out of this that might help figure out what’s going on? It seems like it happens after we spawn our RVO obstacles and have just spawned our first character.

Hi

Found what was causing it!
It was just a stupid assumption I had done which didn’t hold up for when the agent was close to several complex (not a single line) rvo obstacles.

Oh excellent! Is there a patch/change I could apply to my local source until the next release is available?

Hi

A very very quick “fix” would be to open the RVOCoreSimulator.cs file, find the WorkerContext class and make the “vos” array be initialized to a size of say 200 (or some number that is most likely higher than the number of nearby agents + the number of nearby obstacle edges for any given agent).

In my dev version, the RVO system is being refactored quite a lot and the result is not yet ready to be released.

Awesome, I made that change and everything seems to be working great. Thanks for the help with that!

See RVO Beta Version