0
\$\begingroup\$

So in Minecraft, you have the elytra. When you look up, the character moves up. When you look down, the character moves down. The speed you move forward depends on the angle you are moving. I want to do this in 2D.

Let's say that the controls are the following: it's like Learn to Fly where you press left to rotate counter-clockwise and right to rotate clockwise.

I am using a CharacterBody2D in Godot 4. What do I set the velocity to to make this work? I can't just rotate the velocity because the magnitude velocity depends on the angle the player is pointing.

\$\endgroup\$
3
  • \$\begingroup\$ It looks like you have two questions here: 1) "How to adapt Minecraft glider controls to a 2D platformer?" 2) "How to implement this glider control scheme in Godot?" The answers to the second depend on the first, so you should ask one at a time. Try editing your question to ask just the first question. Then once you have an answer you like for the control scheme, you can post a question asking for implementation advice, following that scheme. \$\endgroup\$
    – DMGregory
    Oct 11, 2023 at 20:40
  • \$\begingroup\$ Are you controlling the camera with the mouse in 2D? I don't know how do you want to control it, that is a design problem. The other part is a programming problem, but you got the gist of it: you set the velocity. Most likely what you will to tweak is whatever gravity computation you have, so the character experiences less gravity when gliding. \$\endgroup\$
    – Theraot
    Oct 12, 2023 at 0:44
  • \$\begingroup\$ But what do I set the velocity to? It can't just be the angle of the player times some speed, since the speed is not constant. \$\endgroup\$ Oct 12, 2023 at 19:41

1 Answer 1

0
\$\begingroup\$

I ended up just rotating the velocity only when the player is pressing a button. If someone else has a better way to do this please let me know

\$\endgroup\$
1
  • 1
    \$\begingroup\$ This answer would be even more useful to future readers if you show how you did this, including relevant code snippets. \$\endgroup\$
    – DMGregory
    Oct 12, 2023 at 20:56

You must log in to answer this question.

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