Apple's GameplayKit framework provides pathfinding, goal-based movement, rulesystems, entity-component systems, finite state machines and random distribution classes for game developers. Also included is a class and related protocols for building turn-based AIs based on minmax tree search. Available for iOS 9 and OS X 10.11.
Questions tagged [gameplay-kit]
190 questions
1
vote
1 answer
GKScene SpriteKit error: [SKScene setEntities:]: unrecognized selector sent to instance
I have a code which imports GameplayKit fine, and I can get the GKScene like this:
GKScene * scene = [GKScene sceneWithFileNamed:@"GameScene1"];
Then, I am getting this to GameScene which extends a normal SKScene like this:
GameScene1 * scene1 =…

Vladimir Despotovic
- 3,200
- 2
- 30
- 58
1
vote
0 answers
SpriteKit: two sprites following path at different speeds
I'm making a SpriteKit game where two SpriteNodes are in a maze. That maze is represented as a grid. One sprite (A) travels faster than the other (B). Items randomly pop up, and the sprites have to collect them.
Pathfinding is easy (GKGridGraph is…

retrovius
- 782
- 1
- 10
- 25
1
vote
1 answer
Gameplaykit Pathfinding Enemies
I am currently creating a top down zombie game with spritekit, and I need to implement pathfinding with zombies. I can't find many tutorials on this online, and the few I have found only describe a player and are quite outdated. I have obstacles…

Bruce
- 331
- 3
- 12
1
vote
1 answer
How to add components to sprites within editor with gameplaykit
I have a component:
class Test: GKComponent {
override init() {
super.init()
print("init ran")
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
print("coder init ran")
}
}
I…

Discoveringmypath
- 1,049
- 9
- 23
1
vote
1 answer
SKSpriteKitNode's rotation does not match GKAgent2D's rotation
Hello I am trying to understand basic gameplay kit. But seem to run into trouble with matching the rotation of my agent to that of the spritekitnode on which it is supposed to act. I am using the spaceship which comes with the new game template in…

nata11
- 109
- 1
- 8
1
vote
1 answer
(Apple) GameplayKit State Machine implementation with SKScene
I've read up on the GameplayKit State Machine and the documentation explicitly mention Game UI as an example of usage. Im fully understanding the concept but I am unsure how to implement it while using SpriteKit.
Lets say I want 3 states. Menu,…

Max
- 49
- 1
- 10
1
vote
1 answer
GKObstacleGraph does not handle archiving
I'm using GameplayKit's GKObstacleGraph to add path finding support to my iOS 10.2 SpriteKit game.
The game is a top-down 2D game, it features impassable obstacles which my 'soldiers' can't walk through.
Creating a GKObstacleGraph for my game level,…

David Virdefors
- 11
- 3
1
vote
1 answer
How to Remove an Entity form a SKScene
Components of entities can be removed with:
entity.removeComponentForClass(SpriteComponent.self);
entity.removeComponentForClass(PhysicsComponent.self);
How are Entities removed from a SKScene?
There are plenty of tutorials about removing…

dancingbush
- 2,131
- 5
- 30
- 66
1
vote
1 answer
Removing a Entities GKComponent from a Scene
I am using GamePlay kits Entity - Component system for a 2d game.
Each entity has a sersis of GKComponents - spriteComponent, physicComponent, etc and a GKComponent (ChaseScrollMovement.swift) that takes a Entities spriteComponent and moves it…

dancingbush
- 2,131
- 5
- 30
- 66
1
vote
0 answers
Constraints and collisions with map regions using SpriteKit and GamePlayKit
I'm building a 2D game using SpriteKit and GamePlayKit where units move around the map. One of the things I want to implement is get a notification when a land unit enters specific region of the map (Dot 1). Second thing is constraining warships to…

sasklacz
- 3,610
- 10
- 39
- 58
1
vote
2 answers
Should a GKEntity have properties or methods to access a component's features?
I'm trying wrap my head around game entity systems and using GamePlayKit.
I'm struggling with the following scenario:
RenderComponent is a GKComponent that references an SKSpriteNode to show my entity.
MetaDataComponent is another component that…

Krumelur
- 32,180
- 27
- 124
- 263
1
vote
1 answer
Leaks using GKStateMachine in a Subclass
I will show you my actual code. It has three elements: a Helper:
import SpriteKit
import GameplayKit
class GameSceneHelper: SKScene {
override func didMove(to view: SKView) {
}
}
A subclass of the helper with some game's states:
import…

iOSTony
- 165
- 1
- 11
1
vote
1 answer
Calling costToNode: in subclassed GKGraphNode2D with GameplayKit
Situation
I am using GKObstacleGraph for pathfinding on the following map:
The orange areas are obstacles (GKPolygonObstacle), while the purple dots and lines are custom placed nodes (GKGraphNode2D) and their respective connections, which the…

Filip Juncu
- 352
- 2
- 10
1
vote
1 answer
Where To Handle Mouse Events When Using GKStateMachine
There is just not a lot of information out there about using GKStateMachine and I was wondering where mouse events should be handled. In Apple's "Dispenser" example, they handle the mouse click events in the main scene and I was wondering if that's…

02fentym
- 1,762
- 2
- 16
- 29
1
vote
1 answer
GameplayKit > Make agent stop moving after goal to follow path
I am making an agent follow a GKPath by adding to its behavior the goal toFollow: GKPath. Everything works fine, however the agent continues moving in a 8-like shape when reaching the target point on the path. How do I prevent the agent to wander…

Filip Juncu
- 352
- 2
- 10