Questions tagged [gameplay-kit]

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.

190 questions
22
votes
3 answers

How to conform to NSCopying and implement copyWithZone in Swift 2?

I would like to implement a simple GKGameModel in Swift 2. Apple's example is expressed in Objective-C and includes this method declaration (as required by protocol NSCopyingfrom which GKGameModel inherits): - (id)copyWithZone:(NSZone *)zone { …
Drux
  • 11,992
  • 13
  • 66
  • 116
16
votes
3 answers

GKMinmaxStrategist doesn't return any moves

I have the following code in my main.swift: let strategist = GKMinmaxStrategist() strategist.gameModel = position strategist.maxLookAheadDepth = 1 strategist.randomSource = nil let move = strategist.bestMoveForActivePlayer() ...where position is…
Tim Vermeulen
  • 12,352
  • 9
  • 44
  • 63
8
votes
5 answers

Adding a custom GKComponent to an entity in Xcode SpriteKit scene editor sets GKScene.rootNode to nil

When I add a CustomComponent (GKComponent) to an entity in Xcode SpriteKit scene editor and try to load that .sks file using a GKScene.init, GKScene.rootNode is not set. Even stranger, this happens only on iOS 13 and not on iOS 12. I have a small…
hdsenevi
  • 953
  • 2
  • 14
  • 27
8
votes
1 answer

GKEntity/Component update cycle best practices

The subject My question is about the division of the update cycle when combining Apple's frameworks in order to respect the typical patterns and good practices on the subject, since most of the documentation and example code has not been adapted to…
BadgerBadger
  • 696
  • 3
  • 12
8
votes
2 answers

To use GKAgents or not

I am developing (or atleast trying to develop) a decently big real time tactics game (something similar to RTS) using SpriteKit. I am using GamePlay kit for pathfinding. Initially I used SKActions to move the sprites within the Path but fast enough…
Coldsteel48
  • 3,482
  • 4
  • 26
  • 43
7
votes
1 answer

How to access the object of Navigation graph in SpriteKit scene editor

I am working with SpriteKit and draw a scene by the help of the scene editor in xcode. According to SpriteKit, we can use Navigation graph to draw the paths and I am able to draw a path using navigation graph but i am not able to access this object…
Araf
  • 510
  • 8
  • 32
7
votes
0 answers

GKGoal Avoid Boundary Obstacles

I am seeming to have difficulty keeping my sprite nodes inside a map boundary that I have set up in the following way: I have an SKNode *enemy that moves around an SKScene by goals and behaviors courtesy of GameplayKit from iOS 9. Currently the node…
Will Von Ullrich
  • 2,129
  • 2
  • 15
  • 42
7
votes
1 answer

`-costToNode:` Not Sent to GKGraphNode2D Subclass in GameplayKit

I have what is perhaps a stupid question about Apple's new GameplayKit. I am creating a 2D grid-based node layout for my game. I mostly love the functionality of the GKGraphNode2D, but would like to tweak it in one way. I'd like to conditionally add…
Tim Arnold
  • 8,359
  • 8
  • 44
  • 67
6
votes
0 answers

Agent following path moves forward indefinitely

I am trying to make a sprite move towards a point while avoiding some obstacles. The graph that I am using is a GKObstacleGraph, obtained from this scene: For simplicity I decided not to use a circular physics body for the obstacles, but it's…
Ramy Al Zuhouri
  • 21,580
  • 26
  • 105
  • 187
6
votes
1 answer

Why does my SCNAction sequence stop working intermittently?

I'm trying to move an SCNNode around a scene, constrained to a GKGridGraph. Think along the lines of PacMan but in 3D. I have a ControlComponent which handles the movement of my SCNNode. The logic should go like this... Set the queuedDirection…
gargantuan
  • 8,888
  • 16
  • 67
  • 108
6
votes
2 answers

Where to start with GKMinmaxStrategist?

I was wondering if anyone here has had any luck using GKMinmaxStrategist. This class/feature was showed off at the WWDC, but most of the sample code was in Objective-C, which was a disappointment. The WWDC videos for GameplayKit featured another…
tsb
  • 107
  • 4
5
votes
1 answer

Determine which rectangle a touch point belongs to

In my iOS app, I have many boxes (Quadrilaterals). I wonder what is the best data structure to detect if a touch on the screen is inside which box. I have read about GKRTree and GKQuadTree in the GameplayKit. It appears that none of them are exactly…
5
votes
2 answers

How do you add entities to a Sprite Kit scene using the Xcode Sprite Kit scene editor?

According to the Sprite Kit documentation for entities and components When you add entities (and their components) to a scene in the Xcode SpriteKit Scene Editor, Xcode automatically archive those entities alongside the SpriteKit scene…
James
  • 475
  • 4
  • 12
5
votes
1 answer

How can i model Entities and Components in a effective way in GameplayKit/SpriteKit

Starting with GameplayKit here, I'm modelling an endless runner where the player can swap between characters with a click on screen. The character first can attack in short range (component), the second jumps (component), and the third shoots…
5
votes
1 answer

How to interpret this Swift SpriteKit example code of a physics body bitmask system

I was taking a deep look into Apples SpriteKit & GameplayKit example code and found a Project called 'DemoBots' written in Swift. There are some very interesting concepts used in that projects which I wanted to adapt into my projects. I was already…
1
2 3
12 13