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
1
vote
1 answer

GKShuffledDistribution - using upperbound doesn't exhaust all possible values?

I'm trying to use GKShuffledDistribution in one of my apps but the nextInt(upperBound:) method doesn't work the same as the nextInt method in that it doesn't exhaust all possible values. To demonstrate, open a playground and do this: import…
Jack Ngai
  • 157
  • 1
  • 9
1
vote
0 answers

GameplayKit: suggestion for implementing a GKComponent to fire bullets

I am trying to use GameplayKit to implement all the entities/components of a 2D game made with SpriteKit. The first component that I have created is the SpriteComponent: class SpriteComponent:GKComponent { let node:SKSpriteNode …
Ramy Al Zuhouri
  • 21,580
  • 26
  • 105
  • 187
1
vote
1 answer

GameplayKit GKMeshGraph obstacles bug?

I feel this may be a bug can anyone reproduce or see some error in how I am doing things. I am trying to add GKPolygonObstacle to a GKMeshGraph in a playground for iOS or macOS. import Cocoa import SceneKit import GameplayKit let points =…
Mr Flynn
  • 415
  • 2
  • 10
1
vote
0 answers

Swift 3: Try to convert matrix_float3x3 to SCNVector3

I'm trying to make a 3D game in Swift. I want my enemy to follow a path using a GKGoal. The GKAgent3D has a rotation property type matrix_float3x3, but the SCNNode's rotation property is type SCNVector4. How can I convert matrix_float3x3 to…
Cael
  • 11
  • 2
1
vote
1 answer

Generating random numbers with GKRandomSource

I am using GKRandomSource in a struct to return a random inspirational quote in the view. Is there a way to return that random number and omit the prior entry? That way the user doesn't receive the same quote twice in a row. let inspiration = [ …
VegaStudios
  • 378
  • 1
  • 4
  • 22
1
vote
1 answer

GKScene and SKNode.entity

I've been updating a SpriteKit/GameplayKit project for Xcode 8 and the new Scene Editor which allows adding Entity-Component information to a scene. I've been to move my entity code into the scene, but I'm having trouble accessing the entity from…
Duncan Oliver
  • 39
  • 1
  • 9
1
vote
1 answer

Choose how to split functionality between my components in an ECS

I am currently building a game and I want to use Gameplaykit to organise the elements. I discovered the concept of ECS (Entity Component System) that enables to put functionality in small blocks (called components) that can than be added to an…
Pop Flamingo
  • 3,023
  • 2
  • 26
  • 64
1
vote
1 answer

Obstacles With GameplayKit

Here is my question: How can I convert an SKSpriteNodearray into an array of GKObstacles so that an agent can appropriately avoid these obstacles by using the goalToAvoidObstacles:(nonnull NSArray *)…
Will Von Ullrich
  • 2,129
  • 2
  • 15
  • 42
1
vote
2 answers

GameplayKit Not Pausing When Scene Is Paused

I have a GKAgent2D governing the movement of an SKNode enemy that moves towards a destination. When I pause the SKScene that the agent is moving in, the enemy node seems to continue to move without showing such movement. All of the visible movements…
Will Von Ullrich
  • 2,129
  • 2
  • 15
  • 42
1
vote
0 answers

GameplayKit Delegate Methods Not Getting Called

I have currently a large SpriteKit game in development that uses many different characters and enemies in the game - all of which runs quite nicely as planned. As the levels and gameplay has become more involved however, I am looking to utilize…
Will Von Ullrich
  • 2,129
  • 2
  • 15
  • 42
1
vote
1 answer

Finding a path on a grid with GameplayKit

I am experimenting with Apple's GameplayKit, SpriteKit and Swift. I am trying to wrap my head around pathfinding through tiles which are passable from only one side. The diagram below shows two problems: On the left is a simple solution, I…
Garry Pettet
  • 8,096
  • 22
  • 65
  • 103
1
vote
1 answer

Random Number generation with GameplayKit

I was learning random number generation with swift and Gameplaykit. In the following code, are the numbers generated when I initialize the randomDist and it simply gives a sample from the already generated numbers when I call nextInt or is the…
philoniare
  • 1,625
  • 1
  • 13
  • 20
1
vote
1 answer

GKComponentSystem has no components on update cycle

I’m playing around with SpriteKit and GameplayKit. But when I run my code, the sprite I’m expecting to wander around, does nothing. I used lldb to print out some values, this is the print out: (lldb) po agentSystem.components ▿ 1 elements - [0] :…
Adam Carter
  • 4,741
  • 5
  • 42
  • 103
1
vote
1 answer

How do you determine the order of evaluation of GKRules in a GKRuleSystem?

I'm exploring Apple's GameplayKit APIs and I am currently very confused by the way that GKRuleSystem evaluates its rules. The documentation says that the salience property determines the order of evaluation, with higher-salience rules being…
Uzziel
  • 300
  • 2
  • 6
1
vote
2 answers

GameplayKit -[GKGraph dealloc]: crash on iOS9.2

I wrote a game called "Spiral" with Swift and GameplayKit.But when my GKGridGraph instance dealloc, the app always crash.This happens only on iOS9.2. I have test my code on iOS9.0, everything was all right. Here is the crash calling stack: #0 …
YangXiaoyu
  • 775
  • 4
  • 10