3

The documentation states

GameplayKit also works well for 3D games built with the SceneKit framework

However, there seems to be no mention of using SceneKit's pathfinding features such as GKGraph with SCNNodes that exist in 3d space.

Are GameplayKit's pathfinding feature unsuitable for SceneKit games, or is there extra documentation somewhere to illustrate how to combine the two?

gargantuan
  • 8,888
  • 16
  • 67
  • 108

1 Answers1

2

Depends on the scenario really. My current side project is a SceneKit based boat game; boats move on a 2D plane which means GameplayKit's 2D pathfinding works well.

It's not without complications though... SpriteKit gives you some useful functions such as obstaclesFromSpriteTextures:accuracy:, to help with the generation of your pathfinding graph. There is no corresponding function in SceneKit. I've adopted the approach of rendering my scene 'top down' to an offscreen buffer, and using edge detection to trace around the 2D projection of my islands.

For full 3D pathfinding I can't see GameplayKit being much help, well not without some hacks (eg; break 3D pathfinding down into several 2D planes).

lock
  • 2,861
  • 1
  • 13
  • 20
  • Do you have any pointers on how you created the offscreen buffer? – gargantuan Nov 22 '15 at 15:11
  • I posted the code for a simple offscreen rendering test on [my GitHub account](https://github.com/lachlanhurst/SceneKitOffscreenRendering) a little while back. – lock Nov 22 '15 at 21:29
  • i would suggest to (if the game you are making does not require flying or something) to just use the 2D tools provided with GameplayKit for pathfinding and apply it to the plane of your activity. the rest of the 3rd dimension handling you can probably handle with some custom methods – Will Von Ullrich Feb 28 '16 at 19:29