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\$

2 Answers 2

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .