How would i got about making a Bird like movement in GODOT?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Schnom

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 ] 1 and was wondering how i could make something like it in GODOT codewise

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.

Schnom | 2022-01-09 12:46

:bust_in_silhouette: Reply From: DaddyMonster

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.

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?

Schnom | 2022-01-09 18:00

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 3.0: Rigid Bodies · KCC Blog

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:

RigidBody2D — Godot Engine (stable) documentation in English

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

https://www.youtube.com/watch?v=XSFkAzXQSWE
https://www.youtube.com/watch?v=pnBioV2HkS8

Good luck!

DaddyMonster | 2022-01-09 22:41

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.

Schnom | 2022-01-10 05:57