How to add "Action Points" to Scenekit Game using Gameplaykit or something similar - ios

This is a very common question, and I am not asking for technical details. What I am looking for is an approach or best practice guidance for the following situation:
Imagine a jump and run game entirely made with SceneKit. The game is played by controlling a character running to the right or left side, climbing up walls and jump over obstacles. (it is a 2½-D style game where the character always runs in one direction or it's opposite. Mainly on the x-Axis)
At certain "locations" (on the scene x-axis) I need to implement some specific actions, that should occur as soon as the main character walks, jumps or runs over that specific point.
What I have done so far, is adding simple invisible SCNPlanes with static physics bodies, with the bitmask configured to detect only the contact (no collision). In the physics handler (physics delegate) I can now fetch contact of the objects the character trespasses. Currently I have a large switch-statement to fetch the names of the "Action-Walls" as I call the planes through which the character walks. So, I can trigger whatever specific action that I want to happen at that location.
It is working this way, even quite good, but I wonder if there is a way to add some better "action points" using i.e. Gameplaykit, but I only find information about agents and behaviors or pathfinding.
What I am looking for is some static point, when trespassing it, an associated action happens.
I have no clue about the possibilities of Gameplaykit. Can anyone tell me an approach using Gameplaykit or whatever Apple has in its magic box of useful tools to make this better than using action walls of SCNPlanes and the physics handler?

Related

How can you make an object disappear in ROBLOX over a certain interval?

I'm making a game in ROBLOX, which has a cutscene in it at the start. At the end of the cutscene, the camera zooms up on the character and you spawn in. However, when I spawn in, I can see the dummy I used for the cutscene, so how after a certain interval can you make that dummy disappear?
Does the dummy just need to become invisible? If so, every physical object in ROBLOX (or more formally Part) has a .Transparency field that spans from 0 (for no transparency) to 1 (for full transparency, or in other words, invisible). I don't know what your "dummy" looks like in the object hierarchy, but let's say your dummy were a Model located at workspace.dummy, and that it has a head, torso, left arm, etc. located at workspace.dummy.Head, workspace.dummy.Torso, workspace.dummy.LeftArm, etc. To make the Parts of the dummy invisible, you would have code that looks like this:
workspace.dummy.Head.Transparency = 1
workspace.dummy.Torso.Transparency = 1
workspace.dummy.LeftArm.Transparency = 1
...
And so on. This, however, will make the dummy invisible to all players. If you are making a single-player game, this will not matter; however, if it is a multiplayer game, then this could be a problem. Making the dummy non-transparent again to do the cutscene for a new player would make the dummy visible to all players. If this is a problem for you, there are two things you could do that I know of:
The first and easiest way would be to just have the cutscene take place at a location very far away from where your game occurs; for example, you could shift everything in your cutscene 10,000 studs in the X direction. This would ensure the objects in the cutscene would be out of the render distance of the players playing the actual game, so only the players whose cameras are being manipulated to carry out the cutscene would see it.
The second, more complicated, and not future-proof option involves a very useful bug that is frequently taken advantage of but subject to being fixed at any time since it is not an official feature. This bug is the exploitation of a Camera (or less commonly a Message, which is deprecated) to create what are called local parts—Parts only visible to a certain player. How to create local parts and discussion of benefits and consequences of using local parts is a little complicated and beyond the scope of this answer. Go here if you'd like to learn more. Taken directly from the ROBLOX Wiki at the time of writing:
Local parts are in no way supported by Roblox. They exploit unspecified replication behaviour - at any given moment, the development team could release an update that changes how Camera and Message instances behave, preventing you from making local parts.

Rendering a big grid with SpriteKit

I'm a total newcomer to SpriteKit and game development in general, I've been toying with SpriteKit to make a strategy game set in space.
My backend architecture use a grid system to represent the Universe, I have empty cases and cases with systems/planets/etc...
My grid is backed by GameplayKit GKGridGraph, I use an algorithm that generate a node with random properties for each node of the grid and I subclassed it to add a custom entity to it, which all the properties of this specific universe case.
To render it, I simply use SKShapeNode and SKPriteNode with various colors, shapes and textures.
I enumerate all nodes (GKGridGraphNode) in my GKGridGraph instance, and for each of those nodes I get generate the corresponding SKNode (my SKNode generations is a component of each GKGridGraphNode entity attached object), and I set them a position, and add them as a child to my main node (let's call it mapNode) which is a simple SKNode. In the end it looks like a grid.
It works well for a 30/30 grid, I have 60 FPS while scrolling my grid (custom implementation, I modify my mapNode positon as the user move his fingers).
But as soon as I try a 50/50 or a 100/100 grid, I have literally too many nodes on the screen for the scrolling to works. I know I shouldn't add every of my node on the screen, so I thought about various strategies and I wanted some input on them:
Instead of scrolling my mapNode, I could render only the nodes I see on the screen, and then add/remove nodes as the user scroll left/right/up/down. So it's not really scrolling anymore, it simulate it. I can think of it, but not really how I should implement it in practice. Is it the right solution?
Maybe I could render all my node as one big node? Is there a way to do that? But then I'll loose functions such as nodeAtPosition, which I use extensively to get the entity (custom object) associated with my nodes.
Edit: Actually, my current code is open source, here is the scene in I'm rendering: https://github.com/Dimillian/LittleOrion/blob/master/Little%20Orion/Little%20Orion/scenes/UniverseScene.swift
Is there any other smart way of doing that?
SKTileMapNode was made just for this in Xcode 8
https://www.raywenderlich.com/137216/whats-new-spritekit-ios-10-look-tile-maps
Alternatively, you would only want to load the nodes that are in and near your current view. You would need an algorithm to do this, and would be a big headache compared to tilemaps.
I suspect the algo would involve checking which nodes are in the view's .frame' and then using 'addChild' on them--concurrently, add a reference to them to an array, which you would check against nextupdate()andremoveFromParent` if they were no longer visible ..
It would get hairy trying to optimize this though. The goal would be to load only a few nodes out on each end so that way you have some buffer in moving the camera (less updates).
You could create a math function to pre-determine which nodes are where in relation to the current frame coordinates--so you don't have to iterate through the nodes--but that would require even a lot more work and headache--and it's what people developing on consoles, etc, have to do with high-end games and limited power.
I recommend skimming through a Direct3d/DirectX/OpenGL game development book, just to get an idea of what goes into everything... They aren't hard to find: walk into a bookstore and look for the thickest / heaviest book--that will be the DirectX game development book.
You will see how what we can do with 30 lines in SK requires thousands of lines and vector calculus in C++ and low-level AV frameworks. It will give you an appreciation, understanding, and perspective of game dev, which will help you in your SK journeys :)

How to create "fluid" or "squishy" bacteria-like nodes in swift

I'm currently designing a game in Swift and Spritekit that calls for bacteria-like graphics for the main player. I have no idea how to approach the physics and visual effects of a node like this. If you don't know what I'm talking about, here's a visual:
So basically the player is a circle/oval that can completely alter it's shape based on the surrounding structures.
I've tried this by creating a huge array of nodes strung together to create the larger structure, however this is extremely inefficient and lags the computer when I try to scale it up to multiple players. I also want to fudge this the least amount as possible since it requires realistic (or at least expected) physics of something like this with the ability to jump, move, slide, etc.
Thanks!

collision detection and creation in xcode class

I'm working on making a new app in xcode and have run into two problems that always seem to be a problem when I program large projects.
Basically, I want the user of this app to be able to input specifics like size, position, color, and possibly speed and/or direction.
These inputs will create a square of specific size, position, and color which will move around the screen and interact with other squares the user has created.
Now here are my problems:
First: I have absolutely no idea how to create something in code. I know I almost certainly have to do this in a class, but I've never figured out how to do this in a single programming language.
Second: Interaction between the squares. How do I detect collisions between the possibly dozens or hundreds of squares the user creates.
I'd really like to figure out how to do this, especially because I'm sure it'll be helpful in not only this, but many other future projects.
Thanks
I would recommend using sprite kit for the collision detection and creation of the squares. You'll probably want to subclass SKSpriteNode to define the properties for your squares.
https://developer.apple.com/library/ios/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/Introduction/Introduction.html

powerup in race game

I've got a problem: i need to add a powerup to a racegame, using collision detection.
so i drawed the powerup, but the problem is: It has to be drawn after every 5 rounds and it needs to be placed ramdomly on the track.
Someone with any good advice?
Thanks.
Thats a bit vague. So here is my best shot at an answer.
You would want to use the c# Random class, here are the docs
For a simple game, using rectangular collision should be all you need (I assume thats what you are using) - If you want to randomly generate the power-up position, you will want to create a new Vector2 (the powerups position) with the random generator.
You can use the Next function, to pass in a low, and high variable - which you would need to configure the the bounds you wish the powerup to appear.
My advice as a game designer on the other hand, tells me that randomly located power-ups aren't always the go. It makes it harder to control the games flow and balance, and can very easily result in a flawed final product.
So my advice is a hard coded set of possible weapon spawn points - using a random generator to pick one to place.

Resources