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
0
votes
1 answer
GKState: Why is StateMachine == nil on delegate call?
I'm developing a SpriteKit Game using the GKStateMachine for transitioning between multiple scenes. I'm using a class that holds an instance of the StateMachine, which has multiple states. The states themselves have access to the current SKView…

Ragnar
- 45
- 7
0
votes
1 answer
GKState: Why is self.stateMachine == nil?
I have following Code in my Playground:
import GameplayKit
class TestClass {
var sm: GKStateMachine
init() {
sm = GKStateMachine(states: [MyState()])
sm.enter(MyState.self)
}
}
class MyState: GKState {
override…

Ragnar
- 45
- 7
0
votes
1 answer
How to detect SCNPhysics Intersection between two GKEntities(SCNNodes) in a GKComponent for in SceneKit
I am attempting to detect the intersection of two scnnodes in SceneKit. They are registered as GKEntities. I want to associate a component to both entities that will detect the intersection of their physics bodies using SCNPhysicsContactDelegate,…

Montreaux Rodgers
- 47
- 5
0
votes
0 answers
how to preserve a scene
I'm currently working on a dungeon crawler type of game (in Swift), and I would like to know how to preserve scenes when the game transfers between different scenes.
I know how to save(encode) a scene and reload it. But what I'm trying to do is the…

Bob
- 155
- 1
- 8
0
votes
2 answers
SpriteKit: Removing gravity from SKSpriteNode doesn't work
I'm trying to remove the gravity from SKSpriteNode but is not working. Here is my code:
I add add the SKSpriteNode:
let block: SKSpriteNode = self.childNode(withName: "block") as! SKSpriteNode
I add the gravity thru the Scene.sks
I tried all this…

user2924482
- 8,380
- 23
- 89
- 173
0
votes
1 answer
Prevent GKGridGraph crashing while pathfinding
In my App the Pink heart want to go to the red one! But as you see the way is blocked.
The code I use is:
let solution = GridGraph.findPath(from:…

Just a Human
- 7
- 4
0
votes
0 answers
How to use SKPhysicsWorld without SKScene
I am programming a command line server in Swift for my game which uses physics simulation from SKScene. I've built it as an OS X application using view controller but I couldn't figure out how to port it to command line. The problem I am running…

TheProgrammer
- 11
- 1
0
votes
1 answer
Best practice using GKStates and PhysicsBody operations
I am developing a game using GameplayKit, built on Entity Component Framework, and utilising GKStates.
I would like to know what is the best practice for the following:
I have a game entity, called Person. This person wanders the scene doing their…

Jason
- 1
0
votes
1 answer
How to reset the alignment of physics bodies in SpriteKit?
I´ve made a game with SpriteKit with different bricks falling down on a hill. When these physical bodies fall down they usually bounce off the hill and change their alignment(they spin a couple of times). If I transition to the GameOver scene and…

Jack23
- 19
- 3
0
votes
1 answer
Execution interruption when adding GKObstacleNode to GKObstacleGraph?
I wanted to add an obstacle to the obstacle graph, and interestingly it gives me a runtime error. Is there something that I could be missing or doing that is causing an error?
Playground code
import GameplayKit
let graph = GKObstacleGraph()
let…

MarkoCrush
- 67
- 8
0
votes
2 answers
Deserialize subclass of GKGraphNode using NSKeyedUnarchiver
I want to serialize and deserialize an object of my GKGraphNode subclass using NSKeyedArchiver and NSKeyedUnarchiver. So I try the following:
//: Playground - noun: a place where people can play
import GameplayKit
class MyGraphNode: GKGraphNode {
…

Ruben
- 1
- 2
0
votes
0 answers
Gameplaykit: agents goals and weights
I'm trying to set up my enemies behaviors so that they will chase the player, while avoiding obstacles (walls and such) and stay sufficiently separated from one another (partial flocking). What I want is for the enemies to get in contact with the…

Uplink001
- 71
- 5
0
votes
1 answer
iOS (Swift) App Fails to Load 251st Sound Resource
After loading two or more audio files 250 times, the app fails to load further files. This appears to happen regardless of the length of the audio files or the duration between consecutive plays.
Error:
SKAction: Error loading sound resource:…

Alex Gausman
- 155
- 1
- 6
0
votes
1 answer
saving the current level the user leaves off at
How would I save the current level that the user is on. I have tried using the fallowing code but it does not work. When the user leaves the game I want the game to pick back up on the level they left off at.
This is in my viewcontroller.swift…

Matt Young
- 5
- 5
0
votes
0 answers
How encode GKComponentSystem object
I'm stuck trying to encode an array.
I have a class as following:
class EnemyMoveComponentSystem: GKComponentSystem {
func updateWithDeltaTime(seconds: TimeInterval, gameScene: GameScene) {
for component in components {
…

Bob
- 155
- 1
- 8