I am currently working with the iOS 8 SpriteKit API's and am having a hard time creating an attractive magnetic force with SKFieldNode. I can create an opposing magnetic force just fine, however I can't reverse the field. Heres what I have currently:
touchField = [SKFieldNode magneticField];
touchField.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:(self.frame.size.height/4 - 34)];
touchField.physicsBody.charge = 3;
This particular field is supposed to be interactive with another SKSpriteNode.
Electric and Magnetic fields are currently broken, as of iOS 8.1. They don't interact with the physics simulation at all.
What's probably causing your other node to move is that its physics body is inside the body you've attached to your field, which the simulation corrects by moving the nodes apart.
Also of note is that if magnetic fields were working properly, you don't need to add a physics body to it - the field node itself is intended to be enough to get the effect.
I've got an open bug report filed with Apple. Filing duplicates increases a bug's priority, so if you file one, mention that it's a duplicate of bug 18785194.
UPDATE: This bug still exists in iOS 8.3/Xcode 6.3 beta 2. I've received a request for more information on my bug report, so at least somebody at Apple is aware of it, but that was four beta versions ago.
UPDATE 2: This bug is partially resolved with iOS 9.0/Xcode 7.0 beta 2. Electric and magnetic fields now work, but custom fields are still broken.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With