Should RVOController be able to move on every frame?

I’m having some issues making the RVOController move smoothly. It would seem that a moving RVOController doesn’t change its position on every frame.

This causes serious problems with the Locomotion System by Rune Skovbo Johansen. The system analyzes the speed of the object it is attached to and places feet to the ground to their correct positions. Short stops in otherwise continuous movement makes it impossible to predict the correct foot positions which results in jerky movement. I managed to partly circumvent the issue by following the RVOController by lerping to its position. Interpolation and Desired Simulation FPS settings on the RVOSimulator are not enough to eliminate all of the jerkiness.

The biggest problem with the jerky movement is that it messes up velocity calculations for my own movement script that uses Vector3.SmoothDamp. I don’t know exactly how the function works, but it seems that the position not changing on every frame results in the velocity getting reset to 0 and thus it is always accelerating from 0 which results in crawling speed.

Here is the code (when RVOController is attached to the same GameObject):
Vector3 nextPosition = Vector3.SmoothDamp( transform.position, currentPath.vectorPath[ currentWaypoint ], ref velocity, 2, maxSpeed ); movement = nextPosition - transform.position; rvoController.Move( movement );

Moving the RVOController by teleporting allows the SmoothDamp function to work correctly but that effectively disables Local Avoidance.
rvoController.Teleport( nextPosition );

My debug prints show that the speed of the object that uses my SmoothDamp movement script with the RVOController is zero or close to zero on roughly every other frame.
void Update( ) { print( ( oldPosition - transform.position ).magnitude / Time.deltaTime ); oldPosition = transform.position; }

The CharacterController works flawlessly with the same code. I have retested my findings by creating a new project containing only the assets in question and the results are the same.

Is this a bug or a design flaw with the RVOController or RVOSimulator? Can you fix it soon? Or is it just a configuration issue and you can help me find the magical settings to make things work? If it can’t be fixed, can you suggest some workarounds?

Some further observations:

When the RVOController is told to accelerate (given a movement vector with higher magnitude on every frame) and

  1. Desired Simulation FPS is 10 and Interpolation is on, it moves on every frame but RVOController.velocity remains the same between simulation updates.
  2. Desired Simulation FPS is 9001 and Interpolation is off, it moves and RVOController.velocity changes on every frame.

In both cases the true velocity of the RVOController goes up and down between frames. The differences are much higher than what could be errors in floating point precision. With low simulation FPS the difference in velocity between two consecutive frames can be more than tenfold. This must be the reason why Vector3.SmoothDamp and the Locomotion System don’t work correctly with the RVOController.

Please help me resolve this issue. The quality of our game project depends on it.

I can’t get it to work. I need to move on and try some alternatives to using the RVOController. It really is a shame as the Local Avoidance system was the main reason I decided to get the Pro version of A* Pathfinding Project. In the worst case, if I can’t create a good enough collision avoidance / deadlock breaking system of my own quickly, I might have to go back to using the Unity3D pathfinding system.

Hi

Hm… might be something odd in how I handle edge cases. I will take a look at it.
As a temporary solution you could do something like this:
`
Vector3 interpolatedVelocity;

void Update () {
interpolatedVelocity = Vector3.Lerp ( interpolatedVelocity, rvoController.velocity, Time.deltaTime*5);
}`

Also, what version of the project are you using?

I hope you can find a solution. Thanks for looking into it.

I’m afraid your suggested temporary solution doesn’t help me. Yes, that would give a velocity that changes on every frame but I don’t really need that for anything. I’ve looked at the velocity values just for debugging purposes. What I do need is the RVOController moving consistently for the SmoothDamp function to work.

I’m using 3.5.2. The issue existed in the previous version (3.5.1), too.

Hi

It seems to be caused at least in some part by some code I put it to prevent it from moving huge distances in case of e.g a single frame GC spike.
If you open the RVOCoreSimulator.cs script, change the length of the frameTimeBuffer array to be 1 instead of 5. With that changed, I can get it to work with a consistent velocity as long as the desired simulation FPS is greater than the actual FPS in the scene (the variations I get are about plus minus 0.01%).
I haven’t found a way to get it to work well when the desired simulation fps is lower than the scene fps though.

I did however find that the rvoController.velocity field is very stable.

I can now get it to work with interpolation with consistent results except during the frames where it recalculates the velocity (there I get a zero velocity). I think I can work around that though.

Interesting stuff. However, I couldn’t see any difference with the frameTimeBuffer array size change. That may depend on the moving script used, though. The movement is still jerky for me with your RichAI script and my own script utilizing Vector3.SmoothDamp still results in crawling speed. Note that neither script use a constant speed or reference rvoController.velocity in any way.

Maybe having a stable velocity is not enough or even the cause of the problem? Could there be a problem where the transform.position of the GameObject the rvoController is attached to is updated?

You need to go deeper. :slight_smile:

Hi

I have managed to improve it. Now it works if the desired fps is much lower or much higher than the game fps, but it doesn’t work that well if the desired fps is roughly the same as the game fps if the game fps varies a lot (it works perfectly when the game fps is steady), it is better than before though. I think this is unavoidable unfortunately since the interpolation code cannot know exactly when the next calculation time will occur.

Try this script.
http://pastebin.com/vrk2u9qW

Double Buffering: Off
Interpolation: On
Desired Simulation FPS: 1000

PS: Isn’t it possible to modify the scripts to use rvoController.velocity instead of the difference in position between adjacent frames?

I replaced the content of RVOCoreSimulator.cs with the code you linked and got this error: Assets/AstarPathfindingProject/Core/RVO/RVOCoreSimulator.cs(204,17): error CS0118:Pathfinding.RVO.Simulator.KDTree’ is a property' but atype’ was expected`
It might be possible to recreate the funtionality of Vector3.SmoothDamp but it’s way beyond my skill. Also, your RichAI.cs script is affected by this issue, as well.

Why can’t the RVOController move its position consistently, if the velocity is consistent? If it is possible to modify movement scripts to use the velocity, it should be possible to modify the RVOController’s position updating script.

At its current state the RVOController does not work as a drop-in replacement for the Character Controller as the same functions can’t be used for controlling them.

I have similar , perhaps related issue as well.

I want the ROVcontroller to move and push around the rigid body , but it doesn’t do a good job at it. When I use my player to move the rigidbody using transform.translate to move the character and push the rigid body objects around it’s fine, but when I let AI controlled agent with ROVController to push the rigid body objects , it barely push them … maybe a pixel at a time.

Rigidbody settings doesn’t really matter as I tried on the lightest possible rigidbody with almost no drags , but it still doesn’t help.

I thought ROV stuff is perhaps as close replacement as possible for Unity’s nav agent but currently, it doesn’t do obstacles and it doesn’t push the rigidbody enough.

I also could not use ROVController.Move to move around my player character, because it jitters around. Perhaps it is the same issue being discussed here.

If I let AI characters to move using translate (inside AIPath) then it seems to work, but then I will be missing out of ROV stuff…

I don’t know what the logic is for ROVcontroller’s movement but somewhere around it must be modifying the transform value of the attached gameobject… And if it is moving say 1 unit forward, then it should behave the same as doing it using translate. (with avoidance with other ROV controllers < and obstacles > )

At the moment, it feels bit sluggish and not production ready.

@castor

I don’t think using transform.position will work for actually moving stuff, I hadn’t thought about that scenario. Maybe if it is switched out to rigidbody.position. Make sure the rigidbody does not have an RVOController because then it will try to not intersect it (and thus not push it around).

Second issue, try raising the desired simulation fps on the RVOSimulator object, if the simulation fps is too low, then it will not have time to stop when it should.

@jpcr
If the simulation fps is around the same fps as the game fps, it is very hard to do that reliably because sometimes it might take 1 frame until the next update and sometimes it might take 2 frames, that makes it hard for the script to compensate. If the update is done everu 20 frames or every 1 frame (so a quite low or a very high desired simulation fps), then it is simpler and the result will be more consistent.
It was not very good in the current released version however, so that’s what I have tried to improve in the version I sent you.
Here are additional files which you might need: http://arongranberg.com/wp-content/uploads/astarpathfinding/rvo.zip

Oops, nevermind that zip. Took the files from the wrong directory.
Use this one instead: http://arongranberg.com/wp-content/uploads/astarpathfinding/rvo2.zip

I replaced the files in the Assets/AstarPathfindingProject/Core/RVO folder with the files in the rvo2.zip. I still get the same error in Unity so RVOCoreSimulator.cs won’t compile and I can’t test the new code. I’m not sure it even matters if you haven’t resolved the position updating issue - it’s useless anyway.

I don’t understand why the simulation fps even a factor in the updating of the RVOController’s position. Can’t the position be changed between simulation steps using the last calculated velocity? Or maybe the simulation could be dependent on FixedUpdate and the position could be interpolated like with Rigidbodies. And how can it be that the position doesn’t change smoothly even when the desired simulation FPS is higher than the framerate?

The Unity3D’s built-in NavMeshAgent component manages to move perfectly smoothly and it has local avoidance. It’s not great, though, as it can get deadlocked in some situations and the pathfinding system itself is very limited. But I seriously may not have any other options if the RVOController can’t be made to move smoothly.

I second jpcr on RVOController issue. I have pro version of Unity and if it isn’t for the runtime generation I could have just used Unity one because even if it is bit limited, it does local avoidance , controller stays inside navmesh and it does move smoothly.

Can we have some ETA or detail on plan about improving ROV stuff?

@jpcr

Ok, sorry.
I will release a new beta version soon. I have managed to improve the smoothness of the velocity even more now. Regardless of the fps it is now completely smooth (in my test cases at least).
One of the major issues I found with the previous code was that the delta time was off by one frame, so it was using the previous frame’s delta time to calculate interpolation movement.

@castor
Also included in the above mentioned beta is rvo obstacles, that will make them stay inside the navmesh if the RVONavmesh component is used.

Cheers, can’t wait for that!

Also, I have posted on the other thread about player controlled character staying inside navmesh. Is this possible in any way? I am asking this, because I used to use Unity’s NavAgent’s move command to move the player controlled character and it allowed the agent to stay inside the navmesh even. It is very nice and convenient since I can make player controlled agent to behave and move the same limited places that the AI controlled agents can.

@castor

You might be able to use
AstarPath.active.GetNearest (myPosition).clampedPosition
That will return the closest position on the navmesh.

(assuming you do not want to use RVO for the player)