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
2
votes
1 answer
GameplayKit: Fine tune control of GKAgent
I'm testing out gameplaykit using spritekit. I've added a GKAgent to my GKEntity and I am making my Entity seek my touches by creating an endAgent at touch position.
This works great. The agent moves naturally and chases my touches. However, I…

hamobi
- 7,940
- 4
- 35
- 64
2
votes
2 answers
"Deep-copy" of Swift dictionary with map()?
I have a GKGameModel that stores its internal state in an array a of Cards and a dictionary b that maps from Ints to arrays of Cards. GameplayKit mandates that I must copy this internal state in setGameModel:.
The following code is meant to…

Drux
- 11,992
- 13
- 66
- 116
2
votes
0 answers
GameplayKit Pathfinding with obstacles and agents
I've been searching for days about this new framework and trying to make usage of some of it's funcionalities,
but... there're some things that are not fitting together for me, the demobot source code isn't helping at some points,
I miss some kind…

Rodrigo Bruno
- 23
- 4
2
votes
1 answer
The protocol method of GKAgentDelegate is not right in Swift?
In GameplayKit, I want to conform the protocol GKAgentDelegate, hence use the delegate method func agentDidUpdate(agent: GKAgent).
The problem is, in this method, the parameter agent is declared as GKAgent, not GKAgent2D, so that I cannot access…

hippo_san
- 360
- 2
- 12
1
vote
1 answer
How to build an Apple GameplayKit GKGridGraph
I am building a turn-based strategy game using Swift and Apple's SpriteKit and GameplayKit frameworks. I am attempting to use the GameplayKit-provided GKGridGraph data structure to represent the map grid and am having problems figuring out how to…

John Cleveland
- 488
- 5
- 17
1
vote
1 answer
How do you update your UI when using a state machine
I'm using swifts stateMachine from gamePlayKit. It works great, but there is one thing I don't understand: The stateMachineseems to be its own isolated island; from what I can tell there is no way to pass in arguments or get callbacks. And this…

Joakim Sjöstedt
- 824
- 2
- 9
- 18
1
vote
1 answer
A pathfinding problem: how to tell water-road situation?
As you see, there is a map and I want to pathfinding to identify which cities are liked each other.
The yellow tiles in the map are the Land, and blue ones are the ocean.
The red font means there is a waterway, and the green font means there
is a…

Wang Ying
- 25
- 4
1
vote
0 answers
how to add a white color as a filter on a SKSpriteNode in Swift
I have added a SKSpriteNode in the scene, and I want to add a white color on it to brighten.
let armySprite = SKSpriteNode(imageNamed: "army_img")
armySprite.position = tile.Position
scene.addChild(armySprite)
armySprite.colorBlendFactor =…

Wang Ying
- 25
- 4
1
vote
0 answers
How do I handle touchDown on a SKShapeNode tile map?
I have a gameboard consisting of a two dimensional SKShapeNode tile map. It actually works great, but I find that the logic in touchDown(atPoint pos: CGPoint) is a complete mess, filled with conditionals:
if viewModel.playerIsUsingSkill {
…

Joakim Sjöstedt
- 824
- 2
- 9
- 18
1
vote
0 answers
Detecting overlap of two SKSpriteNodes without using SKPhysicsBodies?
Looking to find a way to detect pixel-to-pixel overlap between two sprites without involving physics (if possible), because running a bunch of physics calculations each frame seems superfluous.
I have a player sprite and an enemy sprite. The enemy…

dandius_zielth
- 11
- 2
1
vote
1 answer
Why can't I add my component to a GKComponentSystem?
My code:
bunnyE = MyEntity()
var wsc : WrappableSpriteComponent = WrappableSpriteComponent()
wsc.setSprite(sprite: bunny!)
bunnyE?.addComponent(wsc)
wrappableComponentSystem =…

Rahul Iyer
- 19,924
- 21
- 96
- 190
1
vote
0 answers
SKScene not loaded when add GKComponent to GameScene.sks
I am currently creating a 2D game with Swift SpriteKit and GameplayKit.
I have a GameScene.sks file and a GameScene.swift file that is of type SKScene.
Now I wanted to add a Component of type GKComponent. I created my component and added it to one…

Oliver Koehler
- 711
- 2
- 8
- 24
1
vote
0 answers
How do I combine Sprite-Kit and Gameplay-Kit for pathfinding?
I have been using Sprite-Kit to create a tile board for a game. The tiles are made up of SKShapeNodes. There is one player character and one enemy on the board, placed on different tiles (nodes).
Now, I'm trying to use Gameplay-Kit framework to…

Mark Tornej
- 165
- 9
1
vote
1 answer
NSCopy GKGameModel doesn't copy player objects correctly
I am trying to use swift NSCopy to do a deep copy of a GKGameModel's object, including all players and their wallet reference (containing Integers representing their cash).
Using Swift playgrounds I try to credit all copied players with $100, but…

zardon
- 1,601
- 4
- 23
- 46
1
vote
0 answers
my iOS game app is not working on Devices
I create a small iOS game app using SpriteKit in Xcode. It's working properly on simulators but in devices it doesn't create nodes. In code I set to create nodes dynamically, it is working
On Simulator but not working On devices
On Simulator
On…

Dineshprabu S
- 19
- 7