[Solved] New RVO, issues using RVO with no RVO Controller - Agents moving in same world direction

Hi Aron.

I edited this post and removed all the old info, as it ended up being a very annoying user/unity error.

To sum up, I was having issues setting and getting proper targets from the RVOAgent class (I’m using a custom movement script). I was getting erratic results, and after a long time debugging, I found the issue. SetTarget() accepts a Vector2, but I accidently sent in my Vector3 without turning it into a Vector2 (x,z). There are no errors here, since unity will just silently clip your vector into a Vector2(x,y), which is obviously not what I wanted.

I would suggest adding an overload that properly clips a Vector3, or at least prints a warning for users that might have not noticed.

I’ve encountered another issue. Now, when I have more than 1 agent, as soon as 2 agents get into a collision distance, they both try moving out of the way, but are walking in the same direction, It creates a situation where they are just walking side by side to one another.

in the image you can see, they were walking in opposite directions, then the agent to the left started walking together with the one on the right, and they both went off course completely.

Edit - Here is some more information:

Short video showing the problem

You can see in the video, the orange arrow is the direction the agent is trying to move in, and is being fed into the SetTarget() function.

The cyan arrow is the result of CalculatedTargetPoint.

here is the code in question:

//Get the realPosition from the RVO Agent var realPos = m_rvoAgent.Position.Get3DVector(m_rvoAgent.ElevationCoordinate); //Calculate where to walk to so that we follow our path m_nextStep = CalculateNextStep(realPos, out m_shouldArrive, out m_desiredSpeed); //Set that target for the RVO Agent m_rvoAgent.SetTarget(m_nextStep.GetXZVector() , m_desiredSpeed, m_lastRequestedSpeed); //Debug draw the direction DebugExtension.DebugArrow(realPos+Vector3.up, m_nextStep , orangeColor); //Get calculated speed from RVO agent float mag = m_rvoAgent.CalculatedSpeed; //Get Calculated Direction from RVO agent var dir = mag > 0 ? m_rvoAgent.CalculatedTargetPoint.Get3DVector() : Vector3.zero; //Debug draw that arrow DebugExtension.DebugArrow(realPos + Vector3.up*2f, dir , Color.cyan); //Notify locomotion system of the direction we are moving in m_locomotion.DesiredDirection = dir; //Notify the locomotion system of the speed it should move in m_locomotion.DesiredSpeed = mag

after the movement is done (in OnAnimatorMove()) I also update the RVO agent with the new position we have arrived at:

m_rvoAgent.Position = Pos3d.GetXZVector(); m_rvoAgent.ElevationCoordinate = Pos3d.y;

Any Idea as to what might be causing this? It just appears that both agents are trying to move to world right instead of perhaps their own right.

One more update. I’ve made a quick test, and got rid of all my code that talks to the rvo agent, and replaced it with an RVO Controller. Now everything works as expected, agents are properly moving and avoiding each other.

That obviously brings to light the fact I am doing something wrong when reading/writing the target points and properties.

I’d like to have this all working at the same script, especially since there are duplicate properties that both my movement script and the RVO script use, and I’d rather not have to synchronize those between scripts, so any light you can shed on this will be appreciated.

User error, again.

I just miscalculated the returned vector from the system, and that was the issue. Everything is looking good and working now.

Um, no. They definitely use a world space point.
I noticed the documentation was incorrect however (result of me renaming some things without noticing the now incorrect docs). I have updated the docs now: http://arongranberg.com/astar/docs_rvo_fix/interface_pathfinding_1_1_r_v_o_1_1_i_agent.php#a946c2fdc6f12d2d583fa72243c8deace

Note sure which other issues arise from this, and you seem to have it working now… soo

Yeah. Sorry, this whole thread was a result of too many changes I made into my code. Everything was fine with the system, I just had issues converting my old code while updating it. I deleted that part as to not confuse other users.

Which ones are duplicated? (I assume you are using the beta version now, I would understand if you were not using it since there indeed are quite a few variables that belong better in the movement script in the non-beta version).

There are duplicates when it comes to having the RVO controller and our custom movement script.

But in general, radius, height, and center are defined by the character colliders. With the current RVO controller in the beta, things are much better, but at this point I can’t start changing our code base to support the controller, and have to stay with the implementation of having IAgent by the same script as our path follower.