1
\$\begingroup\$

I'm working on a shooter, platformer and everything is going okay so far, but I want to make some enemies that fly over top of the player and swoop around him. How can I make them fly? I've seen people suggest to change the world Gravity but that'd mess up the player. What's the best solution?

\$\endgroup\$
1
\$\begingroup\$

Just use the right combination of forces through applyForceToCenter()

\$\endgroup\$
0
\$\begingroup\$

You can change the gravity for a singe body using

body.setGravityScale(0);

You could then move the bodies with ApplyForce or directly change their position.

\$\endgroup\$
  • \$\begingroup\$ LibGDX, not Unity! \$\endgroup\$ – Jacob Apr 6 '17 at 11:51
  • \$\begingroup\$ This is available in LibGdx libgdx docs \$\endgroup\$ – dfour Apr 6 '17 at 11:59
  • \$\begingroup\$ If so, change the -> to .! :) \$\endgroup\$ – Jacob Apr 6 '17 at 17:31

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.