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
0
votes
0 answers

Better Random Number Ranges In Swift 3

Before I upgraded to Swift 3 (Xcode 8) my random position start looked like this: func randomStartPosition(range: Range = 45...(Int(self.frame.size.height)-45)) -> Int { let min = range.startIndex let max = range.endIndex return…
0
votes
1 answer

GKObstacleGraph How to Find Closest Valid point?

In a scenario where user wants to navigate via mouse or touch to some are of the map that is not passable. When sending the point to GKObstacleGRpah FindPath it just returns an empty array. I want the unit to go to closest (or close enough) passable…
Coldsteel48
  • 3,482
  • 4
  • 26
  • 43
0
votes
1 answer

GamePlayKit GKObstacleGraph save and load

Can GKObstacleGraph be saved to a file and loaded from there ? I cant find anything on this. I would love to save and load precalculated graphs for my levels. I have tried so far NSArray * obstacles = [SKNode…
Coldsteel48
  • 3,482
  • 4
  • 26
  • 43
0
votes
1 answer

presentScene is causing wrong view to load

I have one viewController called NeighborhoodViewController. It loads a scene into the viewController, called NeighborhoodScene.sks. This works absolutely fine. I have rigged up a segue from a specific node in the scene through…
user5480023
0
votes
1 answer

Multiple scenes for one ViewController in game

I have the mechanics of one type of game (a particular puzzle) set-up in one Scene file (mygamescene.swift). I want to stylise the same game differently in two different ways (using different node textures, etc) and show these differently in the…
user5480023
0
votes
2 answers

Add animation to State machine in SpriteKit Error

Hi guys am trying to add this animation to my game state am getting this error override func didEnterWithPreviousState(previousState: GKState?) { Ninja_Run = self.childNodeWithName("Ninja_Run") as! SKSpriteNode //ERROR HERE:RunningState' has no…
0
votes
1 answer

AnyType error in Swift array

Trying to make and shuffle a card deck in Swift, made up of Card objects in an array called cardDeck. Then I want to shuffle it. Relevant code: var cardDeck = [card]() for ind in 1 ... 4 { for ind2 in 1 ... 13 { …
OhDannyBoy
  • 95
  • 8
0
votes
0 answers

Determine when GKEntity has began and ended following GKPath

I have a GKAgent2D component attached to my GKEntity, is there any baked in way of finding out when the GKEntity has began and ended following the GKPath assigned to it in the GKGoal(toFollowPath:…) goal? I need to despawn my sprite once it reaches…
Adam Carter
  • 4,741
  • 5
  • 42
  • 103
0
votes
1 answer

Link SKNode to GKAgent2D?

I am new to GameplayKit as most are given its lifespan, and have been trying to figure out the following.. I have an SKNode *enemy that has already been given quite a bit of work and customization from movement to style, habits, etc. all from…
Will Von Ullrich
  • 2,129
  • 2
  • 15
  • 42
0
votes
1 answer

Increase the speed of GKAgent

I'm developing a game with gameplaykit, I'm trying to increase the game speed with worldNode.speed = 4.0. The animations are faster but the agent (GKAgent) with a certain behavior does not increase speed to move in certain point. How can I do…
Simone Pistecchia
  • 2,746
  • 3
  • 18
  • 30
0
votes
2 answers

Images don't update when loaded until end

I am trying to write a routine to roll a die. I want the face to change several times before landing on the final number. The code below does not show the die changing faces. I added the sleep statement in hopes that it would give it time to…
JeffG
  • 13
  • 3
0
votes
1 answer

GKGridGraph find path not working

I'm trying to make a turn based game, and each enemy should find a path to player node. I'm using gameplaykit's pathfinding, and every time enemy has to make a turn, I make sure to remove other enemies from that GKGridGraph (so that enemy won't walk…
HelloimDarius
  • 695
  • 5
  • 23
0
votes
1 answer

How to show GKPath in GameplayKit

is there a trick to show a GKPath? for example my path: class ScenarioPath: GKPath { //SET // | | | | | | // --A--B--C--D--E--F-- // | | | | | | //6 punti con raggio quasi 600 e lato 500 va bene per scenario 2K *…
Simone Pistecchia
  • 2,746
  • 3
  • 18
  • 30
0
votes
2 answers

Gameplaykit GKState, swift func with two parameters

I'm sure that is a simple question for you. How can I write a func with two parameters with one GKState? UPDATE Apple use func willExitWithNextState(_ nextState: GKState) If I use somefunc(state:GKState) works fine while somefunc(state:GKState,…
Simone Pistecchia
  • 2,746
  • 3
  • 18
  • 30
0
votes
1 answer

How do I use GKRandomSource from Swift's Gameplaykit to shuffle questions

I'm new to Swift and iOS development and am doing a number of online courses. In one course I completed an iPhone quiz app. All the questions and potential answers are loaded from a .json file and the code we worked through randomly selects a…
Monomeeth
  • 753
  • 3
  • 13
  • 29
1 2 3
12
13