2

The title is my direct question, but I will elaborate to provide context, or detail what is needed for a helpful workaround if the answer is: You can't, log Radar with Apple

Use case is simple: Have a behavior driven GKAgent3D avoid a plane in my ARKit/SceneKit/GameKit app.

This requires I add a 'toAvoid' GKGoal as a behavior of the agent. Apple currently provides two things to avoid, other GKAgents or GKObstacles. The problem I am having is that I see no way to create a GKAgent3D or GKObstacle for use in SceneKit that is not a sphere. GKAgent3D only has a .radius property to define it's "occupied space" and GKObstacle only has one 3D concrete subclass (GKSphereObstacle) and the obstacles(from:) functions use SpriteKit objects.

I have many agents that all have complex behaviors and there are many planes I'd like them to avoid (ARKit detected). I would rather not resort to manual collision detection, since the goal is to have the agents alter their behavior driven path as a result of the object being in the way. It is not enough to just know that the agent is going to hit the object, I need to have that fact influence it's movement considering all the other goals it has in it's behavior.

I am hoping I am missing something and there is a way to do this, or that someone has a clever workaround. The only workaround I have thought of (but hate for performance reasons) is creating a massive number of small sphere obstacles in a regular array to approximate the surface of the plane.

Swany
  • 615
  • 8
  • 14
  • Finding no answer here and getting no help from Apple, I resorted to building a matrix of GKSphereObstacles centered on the detected plane. I had to overlap them about 60% to avoid "holes" in the matrix that allowed very small objects to penetrate. To mitigate performance degradation, I dynamically size the spheres, making them as large as reasonable (based on the plane size), and I discard the matrix as the user moves away from the detected plane (since the moving objects near the plane get too small to see and then penetration no longer matters). – Swany Apr 05 '18 at 21:34

0 Answers0