Running on the Oculus Quest + Collision avoidance

So it took me a bit of fudging (and a lot of logcat), but I finally got AStar 4 + Unity 2020.1a running on the Quest. The culprit: Something about the Burst-enabled recast scan gives Burst indigestion on mobile. Once I commented that bit out in the source, it worked! And performance wise? 30 agents recalculating every 500ms isn’t free, but it’s small enough that framerate stayed locked at 72!

My results:

What I’m having trouble with: So my agents are obviously fully physicalized and generally just doing their best to aim at the next point in the path and slam the throttle, but they’re… Well… Impolite. I can’t figure out how to make stop ramming each other though - RVO doesn’t seem to quite fit the mold, and using the ‘Alternative Paths’ modifier seems to generate random paths every single time so when I have it on, the agents just wobble indecisively in place. Tips?

Bump… Does anyone have any help with collision avoidance that’s not using the built-in RVO controller? I can’t get my guys to stop ramming each other :frowning:

Hi

There is nothing for this built-in to the package, but I would recommend using some kind of steering behavior based on raycasts.
You can for example take a look at https://www.red3d.com/cwr/steer/
and https://gamedevelopment.tutsplus.com/series/understanding-steering-behaviors--gamedev-12732

Interesting that burst caused a problem… Do you have any idea or logs about what caused it more precisely?

Yeah, specifically RecastMeshGathererBurst.cs:82. It looks like it can’t be marshaled when burst is running on android. I’ll collect a more detail log later - compile times are a killer…

Thanks for the tips, I’ll follow up!

PS: To clarify, it’s JUST RecastMeshGathererBurst that fails. Every other burst-y function runs fine!

Thanks!
Would you mind posting the contents of that line in your version? The line numbers change between versions and they are also different between my dev version and the uploaded version.

Do you have the exact error message (if you have it logged somewhere)?

Here, I’ve rebuilt it without my modification and the log says:

2020/07/12 12:48:50.036 3515 3545 Error Unity MarshalDirectiveException: Cannot marshal P/Invoke call through delegate of type '.CalculateBoundDelegate'
2020/07/12 12:48:50.036 3515 3545 Error Unity   at System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer[TDelegate] (System.IntPtr ptr) [0x00000] in <00000000000000000000000000000000>:0 
2020/07/12 12:48:50.036 3515 3545 Error Unity   at Pathfinding.Recast.RecastMeshGathererBurst..cctor () [0x00000] in <00000000000000000000000000000000>:0 
2020/07/12 12:48:50.036 3515 3545 Error Unity   at Pathfinding.RecastGraph.CollectMeshesBurst (UnityEngine.Bounds bounds) [0x00000] in <00000000000000000000000000000000>:0 
2020/07/12 12:48:50.036 3515 3545 Error Unity   at Pathfinding.RecastGraph+<ScanAllTilesBurst>d__53.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
2020/07/12 12:48:50.036 3515 3545 Error Unity   at Pathfinding.RecastGraph+<ScanInternal>d__46.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
2020/07/12 12:48:50.036 3515 3545 Error Unity   at AstarPath+<ScanGraph>d__143.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
2020/07/12 12:48:50.036 3515 3545 Error Unity   at AstarPath+<ScanInternal>d__142.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
2020/07/12 12:48:50.036 3515 3545 Error Unity   at AstarPath.Scan (Pathfinding.NavGraph[] graphsToScan) [0x00000] in <0000000000000000000000000000

Thanks!
Hmmm… I think I know how to solve that.

Would you mind trying this:

  1. Open the RecastMeshGathererBurst.cs script
  2. Find the CalculateBounds method
  3. Add the attribute
[AOT.MonoPInvokeCallback(typeof(CalculateBoundDelegate))]

to it.

After this the method should look like

[BurstCompile]
[AOT.MonoPInvokeCallback(typeof(CalculateBoundDelegate))]
static void CalculateBounds (ref NativeSlice<float3> vertices, ref float4x4 localToWorldMatrix, out Bounds bounds) {
  1. Re-enable burst scanning that you disabled earlier.

That did it! Compiles and runs beautifully now, problem solved.

Well, the burst thing is solved. Making my guys stop ramming me is another thing. :confused: