This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

So i looked for a few Tutorials for a certain kind of movement for a 2d Game Idea i had, where you control a 2d Bird, controlling when it speeds up with flaps and how its tilted, pretty similiar to a simple Airplane.
I found a short Article on it for Unity and was wondering how i could make something like it in GODOT codewise

Godot version v3.4.2
in Engine by (20 points)

Bump but also to add: At the end of it the Player should basically glide trough a 2d scene, being able to tilt upwards or downwards and accelarete by pressing the space bar.

1 Answer

+1 vote
Best answer

This could be done easily enough just by adding a rigidbody. I'd probably make a flapping animation and have an AnimationTree node to manage it. To manage movement, you'd want to add_central_force (or an impulse, depending on the outcome you're after) feed in the transform.y so that it applies to the bird's up which you could scale depending on where you are in the animation. You'd probably want a forward force for the thrust too, depends on your game.

For the rotation I'd use _integrate_forces, something along these lines:

func _integrate_forces(state):
    state.transform = state.transform.rotated(angle)

nb. unless you're very good at maths, you'll be opening yourself to world of pain if you try to control the bird's pitch with apply_central_torque so I'd advise steering clear and using _integrate_forces as above.

by (2,159 points)
selected by

Okay i feel really dumb asking this but im a noob at GODOT and generally with coding:
How would i go best about building this Code in?

Oh, don't worry, we were all in that same boat at one point. Start by making sure you watch a few introduction to Godot vids and read the introduction to Godot in the docs. The docs in Godot are your friend so just read the first few pages. You need to know your way around the editor, how to add a script and what nodes and scenes are before you begin.

For rigidbodies, take a look at KidsCanCode:

Godot website has a few MIT licensed demos in the docs so you can take a look and you're free to copy the code there into your project:

Finally, here's some nice video tutorials to get you going:

Good luck!

Thanks for the tips and links!
I did watch a tutorial series before so i atleast know the basic, but those should help adancing my knowledge.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.