Currently I am making a clone of the game Flappy Bird for practice. I am representing the bird as a RigidBody2D
.
extends RigidBody2D
func _ready():
pass
func _input(event):
if Input.is_action_just_pressed("input_action_flap"):
bird_flap()
func _physics_process(delta):
print(self.rotation_degrees)
self.rotation_degrees = -45
print(self.rotation_degrees)
func bird_flap():
var des_linear_velocity_x : float = get_linear_velocity().x
var des_linear_velocity_y : float = -750
var des_angular_velocity : float = -3
set_linear_velocity(Vector2(des_linear_velocity_x, des_linear_velocity_y))
set_angular_velocity(des_angular_velocity)
I am playing around with ways to limit the possible rotation of the Node. However, I am running into some issues.
-135.234329
-45
-137.498474
-45
-139.724884
-45
-141.914169
-45
-144.066986
-45
-146.183914
-45
-148.265564
-45
-150.312515
-45
-152.325363
-45
The values of the rotation seem to be flickering wildly due to Godot's built-in physics engine. And when I try to use the method clamp(...)
- I subsequently experience wild flickering of my character sprite's rotation.
self.rotation = clamp(self.rotation, deg2rad(-45), deg2rad(+45))
Does anyone know how to fix this?
_integrate_forces(...)
is called? I am weary of using it without a proper understanding of when exactly the method is run... – Parallelogram