3
\$\begingroup\$

I am creating space game which has an effect similar to black hole's gravitational effect. Wherever the spaceship is going, the black hole will attract it, summing up all the vectors together.

I know SKFieldNode has a method customFieldWithEvaluationBlock: that allows to calculate everything myself, but might it be another way to do that?

I have tried almost every type in SKFieldNode, but nothing helped.

  1. There are some side effects that don't suit me (i.e. If I use an electric or magnetic field, the object repels from the black hole)
  2. Moreover, moving with SKAction (i.e. for the spaceship) doesn't allow me to sum all movement vectors together (I cant do - (void)moveTo:duration: actions simultaneously, even with grouping the actions)

What can you advice me? !

\$\endgroup\$
  • \$\begingroup\$ Beraliv, I deleted greetings part because they are frowned upon by the community members. If you take a look at the other questions, you see what I an saying, please don't take it personally. Did you test vortexField? \$\endgroup\$ – Zich Sep 10 '15 at 17:53
  • \$\begingroup\$ @lman thanks, I understood. Yeah, I tested it, need to adjust the parameters to check if it suits. \$\endgroup\$ – Beraliv Sep 10 '15 at 17:56
  • \$\begingroup\$ did you succeed to use vortedField for your blackhole? please share your experiance. \$\endgroup\$ – Zich Sep 16 '15 at 21:28
1
\$\begingroup\$

to simulate a black hole, I suggest to use SKFieldNode and vortexField(), adjust its strength and falloff property (default is 2).

Setting a big number for strength will makes a big perpendicular force which simulates an angular force too (tangant to its imaginary orbital path around the black hole).

And let the physics handle the rest, just dont touch any thing else and only use physics rules.

Do not apply any force vector manually

\$\endgroup\$
  • \$\begingroup\$ @lman I was helped with this stackoverflow.com/questions/31500104/… counting it myself, its close to what I wanted to. \$\endgroup\$ – Beraliv Sep 18 '15 at 12:02
  • \$\begingroup\$ @Beraliv goodluck, but I don't understand why you couldn't use SpriteKit fields method, they are much more optimized than an update method code. \$\endgroup\$ – Zich Sep 18 '15 at 12:33
  • \$\begingroup\$ @lman ok, how can I stop the spaceship around the blackhole and then try to scale it with this field? \$\endgroup\$ – Beraliv Sep 18 '15 at 12:35
  • \$\begingroup\$ @Beraliv Scale what? I don't follow, You will have a black hole that its force increase by getting closer to it, and at a specfic distance your spaceship engine force and the blackhole gravity will be equal and the spaceship miss the chance to escape. a little before that if your space ship moves towards an orbital tangent direction the BH gravity and the spaceship tangent force will create an orbital path which I believe you are looking for. What do you mean by scale? do you mean how to increase black hole gravity? set strength property of your vortex \$\endgroup\$ – Zich Sep 18 '15 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.