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

Swift - SpriteKit game, player disappears when adding player?.run(move)

Working on a designcode.io tutorial for making a SpriteKit game. Have an issue where adding player movement causes the player image/texture to disappear. Code snippet of the update() function below. Commenting out the last line player?.run(move)…
Corey
  • 1
  • 2
0
votes
1 answer

Exact path following in GameplayKit

I have a simple SKScene based game. I have a path that I've created using GKGridGraph.findPath and I want my agents to follow that path exactly. I've set up the agent to follow the path, with a radius of one, so it should be a pretty narrow path…
stevex
  • 5,589
  • 37
  • 52
0
votes
1 answer

GameplayKit: Enemy agent overshoots destination point during seek behavior

I'm trying to incorporate GameplayKit into a SpriteKit project. Specifically, I'm trying to use GameplayKit's seek-and-avoid behavior wherein an "enemy" character chases a moving "player" character while avoiding obstacles. I have managed to make…
West1
  • 1,430
  • 16
  • 27
0
votes
1 answer

Why are my GKAgent2D's position and velocity nan?

Using GameplayKit, I'm trying to make an enemy character pursue the player while avoiding obstacles in a SpriteKit game. However, the agent in agentDidUpdate(_:) has a position and velocity of nan. Here's what I'm doing now: Configure the…
West1
  • 1,430
  • 16
  • 27
0
votes
1 answer

Xcode 12.5 NSCoding issue with SpriteKit/GameplayKit

I'm working on application using SpriteKit and I'm having trouble with NSCoding on a particular object (a GKComponent object). I'm using Swift 4.0 and iOS 11 in Build Settings. The application always crashes on the line (marked with //***) where I'm…
Bob
  • 155
  • 1
  • 8
0
votes
0 answers

How do I use the same variable across multiple states for a state machine?

I'm using Gameplaykit's GKStateMachine to create a state machine for my game, but I run into an issue where I need to use the same variable inside multiple states. If I send them in with the init, then the variable will act independently of the…
Joakim Sjöstedt
  • 824
  • 2
  • 9
  • 18
0
votes
1 answer

How can I sort all elements in a complex set of GKEntity?

I have 4 classes like D_Entity,P_Entity,T_Entity and O_Entity,which have been defined as follows: class D_Entity : GKEntity { var S_Comp : S_Component! ............. } class P_Entity : GKEntity { var S_Comp : S_Component! …
Wang Ying
  • 25
  • 4
0
votes
1 answer

How can I animate a moving GKAgent2D with a goal in Swift using Spritekit and GameplayKit?

I am building a game in Swift using Spritekit and GameplayKit. I am currently having trouble animating the AI-enemy that competes against the player. In the game, players collect falling objects from the sky which they use to plant flowers. The…
parkcoop
  • 33
  • 1
  • 7
0
votes
1 answer

How to use alpha component in gradient colors with GKNoise and SKTexture?

I'm using GKNoise with a gradient map to generate color noise, getting a CGImage via SKTexture, on Mac OS. In particular I'm using a GKPerlinNoiseSource and setting two gradient colors, at values -1.0 and 1.0. It works as expected if the two colors…
Corbell
  • 1,283
  • 8
  • 15
0
votes
1 answer

How to save and load GKGameModelPlayer from Realm in Swift?

I am attempting to implement a GKGameModel in my application. In it, it holds variables to a few things, but for the purposes of my question I'm interested in the following two variables: import GameplayKit final class GameModel: NSObject,…
zardon
  • 1,601
  • 4
  • 23
  • 46
0
votes
0 answers

Apparently random execution time with GKGraph.findpath() method in Swift

I'm having a pathfinder class in a SpriteKit game that a I want to use to process every path request in the game. So I have my class stored in my SKScene and I access it from different parts of the game always from the main thread. The pathfinder…
Onoulade
  • 138
  • 10
0
votes
1 answer

How to pass scene type to a function in a generic manner?

I have the following boiler plate code generated by Xcode when creating a SpriteKit + GameplayKit project: override func viewDidLoad() { super.viewDidLoad() // Load 'GameScene.sks' as a GKScene. This provides gameplay related content //…
Rahul Iyer
  • 19,924
  • 21
  • 96
  • 190
0
votes
1 answer

How can I use GameplayKit State Machine for sprite animation?

I have two animations for my player to run and jump. Can I control these animations using GameplayKit's state machines? If so, how? In this project, I use SpriteKit and GameplayKit for Entity-Component architecture and State Machine.
Vladislav Kulikov
  • 415
  • 1
  • 3
  • 11
0
votes
1 answer

How to create a SKSpriteNode with Custom GKComponent?

So im currently working on a game with spriteKit and gameplayKit. I've created a custom GKComponent class that I'm giving to certain SKSpriteNode via the scene inspector in Xcode (image). Now, when I want to re-create random SKSpritenodes with the…
Sash
  • 28
  • 1
  • 6
0
votes
0 answers

Pathfinding with GameplayKit: Sprite acts weird when I try to make it follow a touch

So I was trying to implement pathfinding in my SpriteKit game (the user touches the screen and a sprite makes its way to the touched point while avoiding obstacles). The following code is what i've gone for (this snippet is located in the custom…
Ferb300
  • 53
  • 4