2

SKNode has a position property which represents the node's position in parent. Whereas GKAgent2D also has a position property which according to the documentation is its position in 2D space. How are these two related? And how do we convert between each other and is a conversion necessary?

nata11
  • 109
  • 1
  • 8

2 Answers2

2

You can use GameplayKit without SpriteKit. The Agent's position is internal to GameplayKit and then you synchronize your sprite's position to your agent's position. It means you can also have agents with other frameworks.

BadgerBadger
  • 696
  • 3
  • 12
  • If GameplayKit's coordinate system is independent of SpritKit then would be best to assume that agents in GameplayKit should share the same origin or for that matter force it be so? – nata11 May 04 '17 at 14:13
  • It all depends on what you are doing. Just don't get confused with the automatic integration with SpriteKit. The two are not tied together. – BadgerBadger May 05 '17 at 14:26
1

GKAgent2D position is arbitrary to whatever system you are using it for, you so there is no exact need to convert it. Now to keep your game simple and easy to understand, you are probably going to want to keep everything based on the scene coordinates, so you are going to want to convert your SKNode position to the position it is at on the scene, this way you can keep all of your GKAgent values based on scene position as well.

Knight0fDragon
  • 16,609
  • 2
  • 23
  • 44