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?
2 Answers
\$\begingroup\$
\$\endgroup\$
Just use the right combination of forces through applyForceToCenter()
\$\begingroup\$
\$\endgroup\$
3
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.
-
\$\begingroup\$
LibGDX, notUnity! \$\endgroup\$Jacob– Jacob2017-04-06 11:51:57 +00:00Commented Apr 6, 2017 at 11:51 -
\$\begingroup\$ This is available in LibGdx libgdx docs \$\endgroup\$dfour– dfour2017-04-06 11:59:46 +00:00Commented Apr 6, 2017 at 11:59
-
\$\begingroup\$ If so, change the
->to.! :) \$\endgroup\$Jacob– Jacob2017-04-06 17:31:27 +00:00Commented Apr 6, 2017 at 17:31