Questions tagged [skfieldnode]

A SKFieldNode applies physics effects to physics bodies within a specific part of a Sprite Kit scene.

17 questions
4
votes
0 answers

radialGravityField goes nuts after a while

I'm trying to create a SpriteKit game using Swift that looks somewhat like a 2D gravity simulator, but when my objects approach a bit they go to the opposite direction with crazy speeds. This may be related with the minimumRadius, categoryBitMask or…
Tiago Marinho
  • 2,146
  • 17
  • 37
3
votes
1 answer

choose what objects radial gravity fields affect swift

I'm working on an Xcode project with swift and sprite kit, and I'm wondering how I can choose which objects are affected by radial gravity fields. I currently have two stars and some planets, and each star has a radial gravity field following it.…
Nightman
  • 49
  • 1
  • 8
2
votes
0 answers

How do I make a repulsion barrier around the edge of my screen?

func initializeBorederBlocks() { let upperBorderBlock: SKFieldNode = SKFieldNode.linearGravityField(withVector: vector3(0, -5, 0)) upperBorderBlock.region = SKRegion(size: CGSize(width: self.frame.size.width, height: -10)) …
2
votes
1 answer

Difficulty with orbiting a SKFieldNode in SpriteKit

I'm trying to get a simple SKSpriteNode to perfectly orbit an SKFieldNode.radialGravityField() once it comes into its defined SKRegion. I have the gravity of my scene set to zero via self.physicsWorld.gravity = CGVectorMake(0.0, 0.0). I am trying…
justColbs
  • 1,504
  • 2
  • 18
  • 28
2
votes
1 answer

SKFieldNode positioned wrong after iOS 9 update

I've some code that worked perfectly fine in iOS 8, however since iOS 9 a few SKFieldNodes behave very strangely. The image below shows a scene with two SKFieldNodes (marked with red sprites) and a SKEmitterNode emitting gold-ish particles. In iOS…
Double M
  • 1,449
  • 1
  • 12
  • 29
2
votes
2 answers

SpriteKit SKFieldNode: Why can't I move the field during runtime?

I am trying to move a SKFieldNode (radialGravity) during runtime: let movingField = SKFieldNode.radialGravityField( movingField.position = location //location is a touch position addChild(movingField) It crashes as soon as I command the field node…
Z3lda
  • 21
  • 2
1
vote
1 answer

Create a SKNode attracted to larger node via an SKFieldNode without moving the larger node

In my game, I have a larger SKNode that uses an SKFieldNode radial gravity field to attract other, smaller nodes towards it. This results in the larger node being moved by the force of the smaller nodes, which isn't optimal for my game. (For…
1
vote
1 answer

SKFieldNode with circular region only affecting bodies when center is within region

Ok so from the SKFieldNode documentation, under the region property: A field node applies its effect to all physics bodies that are partially or completely inside its region. The default value is a region of infinite size. From this I understand…
1
vote
1 answer

Properly setting up SKFieldNode.categoryBitMask & physicsBody.contactTestBitMask

I'm trying to make an invisible boundary, with the SKFieldNode, that sends an NSLog(@"Contact registered between bird & field node."); through didBeginContact method when a sprite is inside the SKFieldNode radius. I think I set up the code…
Krekin
  • 1,516
  • 1
  • 13
  • 24
1
vote
1 answer

Can an SKFieldNode be used to also alter the zRotation of a particle?

I'm trying to make an SKFieldNode attract water particles toward the node when using an SKEmitterNode as the particle system. When moving toward the SKFieldNode's location using a field like the radialGravityField, I want the particles to also…
Patrick Collins
  • 4,046
  • 3
  • 26
  • 29
0
votes
0 answers

How to show SKShapeNode inside another SKShapeNode and separate fields

I want to show circles inside another circles. I have SKScene with radialGravityField. Big circles (SKShapeNode) have physicsBody. self.physicsBody = { let path = SKShapeNode(circleOfRadius: radius).path! let body =…
Mak
  • 9
  • 4
0
votes
1 answer

Make an SKFieldNode affect an SKSpriteNode when the sprite's velocity is being explicitly set?

I have a SpriteKit scene with an SKFieldNode.linearGravityField(withVector:) and an SKSpriteNode that has a physicsBody. The user moves the sprite with their finger. I'm moving the sprite by explicitly setting its velocity in update(_:), which…
West1
  • 1,430
  • 16
  • 27
0
votes
1 answer

How to exclude positions in a field in SpriteKit?

I have a function that spawns little balls, randomly positioned, on the screen. The problem I face is that I want to distribute the balls randomly, but when I do so, some balls spawn on top of each other. I want to exclude all the positions that are…
0
votes
1 answer

Sprite-Kit: How to visualize an SKFieldNode

I am currently working on a magnetic field within my Sprite Kit game. Here's the initialization code: private func initMagneticField(_ object: TileMapObjectMagneticField) { let field = SKFieldNode.magneticField() field.strength =…
salocinx
  • 3,715
  • 8
  • 61
  • 110
0
votes
1 answer

Magnetic field affects unwanted sprite

I have a Player Sprite which moves as the user drag their finger across the screen. I have implemented a power that the player sprite creates a magnetic repulsive force around it. My dilemma is that when the power is turned on the player sprite…
jtmwanakhu
  • 623
  • 1
  • 6
  • 17
1
2