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
Prevent Node From Leaving Boundary
I am using GameplayKit to create paths around obstacles in a given map boundary (lets say a rectangle 1000x1000).
I know that you can make certain nodes avoid "obstacles" when pathfinding, which I am using quite nicely. What I am curious about…

Will Von Ullrich
- 2,129
- 2
- 15
- 42
1
vote
0 answers
Prevent Location Offset With SpriteKit Camera Node
I have noticed that the centerOnNode: method as shown,
- (void)centerOnNode:(SKNode *)node {
cameraOffset = [node.scene convertPoint:node.position fromNode:node.parent];
node.parent.position = CGPointMake(node.parent.position.x -…

Will Von Ullrich
- 2,129
- 2
- 15
- 42
1
vote
2 answers
How can I save the previous state in a way that allows it to be entered again with GKStateMachine?
I am using GKStateMachine to keep track of the state of tiles in my game.
When I place an item, the tiles that are covered by the item are put into a "planned" state. How can I store and then return the tiles to the previous state at a later…

Relequestual
- 11,631
- 6
- 47
- 83
1
vote
2 answers
How do I 'seed' using GKRandomSource from Swift's Gameplaykit to remember the shuffle between sessions
I'm new to programming and have been learning Swift by doing a number of online courses. In one of the courses we built a basic trivia game and I've been progressively trying to improve it by doing my own coding (best way to learn!).
Recently I came…

Monomeeth
- 753
- 3
- 13
- 29
1
vote
1 answer
What is the syntax to store a Class as a value in a Dictionary in Swift?
Lets say I want to do this:
class foobar : NSObject {
//method declarations, etc.
}
Then later:
let myDictionary:Dictionary = ["returnMeAnAwesomeClass":foobar]
Does not work.
If I put in foobar.Type, it also doesn't work.
If I put in foobar.class…

CommaToast
- 11,370
- 7
- 54
- 69
1
vote
1 answer
GKGraph Incorrectly Calculates Path with GKGraphNode2D-Subclassed Nodes
I started investigating this issue with this question which was partially resolved in the iOS 9.2 SDK.
However, upon further investigation, I realized that this framework was still not working as expected.
In summary, a GKGraph can be constructed…

Tim Arnold
- 8,359
- 8
- 44
- 67
1
vote
1 answer
using GKAgents to move sprites from left to right and back
I'm looking for a way to move a GKAgent from left to right across a screen. The agent is connected to a GKEntity and I've created two further agents, called "leftWall" and "rightWall". For each agent, there is a matching sprite node with a unique…

Shane O'Seasnain
- 3,534
- 5
- 24
- 31
1
vote
1 answer
Wait until property is true before continuing loop
Trying to do something I feel like should be simple but nothing I've tried so far works. I'm trying to prevent this loop from continuing until a property on my enemy is set to true.
My enemy node figures out a path to the player during the walk…

Negora
- 281
- 4
- 13
1
vote
0 answers
Pathfinding no longer works after blocking and unblocking path
I have a map with obstacles that can be placed by the user. And sprites that move from the right of the map to the left.
As the user places obstacles they're added to my game's graph (GKObstacleGraph) and each time I check if a path from the start…

thebro
- 305
- 2
- 11
1
vote
1 answer
SpriteKit Array Error SKNode.obstaclesFromNodes
I'm trying to create an array of obstacles from the nodes in my SpriteKit game. I created a new project to try and solve the error and found it still happens.
This is the code in the new project:
import SpriteKit
class GameScene: SKScene {
…

thebro
- 305
- 2
- 11
1
vote
1 answer
GKGridGraphNode with custom traversal cost
I was following this tutorial
http://blog.lukasjoswiak.com/gameplaykit-for-beginners-part-1/
and when I got to the end, I wanted to try to make the towers not completely impassable, but just have a higher cost.
so, I subclassed GKGridGraphNode and…

Weston
- 1,481
- 1
- 11
- 31
0
votes
0 answers
Swift GCD DispatchQueue
I'm writing a game using SpriteKit and GameplayKit, where a lot of entities use pathfinding logics to move around. Therefore I want run the pathfinding code in the background.
However, I occasionally get a EXC_BAD_ACCESS error from either of these…

Bob
- 155
- 1
- 8
0
votes
1 answer
GameplayKit: Stop Pathfinding When Path Is Blocked By Certain Obstacles
I have a SceneKit project into which I'm trying to integrate GameplayKit's 2D pathfinding capabilities.
What I have are 2 different kinds of obstacles (let's call them "good obstacles" and "bad obstacles"). The main character can touch the good…

West1
- 1,430
- 16
- 27
0
votes
1 answer
GKBehavior/GKGoal causing chaos with position
I'm trying to get a GKActor to position SKNodes in a scene. I thought I had this working. However, when I add a GKBehavior to the actor, I get very erratic position changes flicking all over the place and the actors behaviour isn't working.
I'm…

Benjamin
- 663
- 8
- 23
0
votes
0 answers
Is it possible to get a GameplayKit component by super class
In GameplayKit, is it possible to have a Component class hierarchy and to get the child component calling for it parent class?
For example if we have:
a Component class BComponent that extends AComponent.
an Entity for which we add the component B…

PujolDeveloper
- 43
- 4