Godot Version: 4.3
Question: Help please!! I’m trying my best at coding a my first game in godot. I’m trying to do a flappybird clone game, I’m working on the script of the bird but when I jump it rotates upwards but it doesn’t rotate to downwards. I dunno what is wrong with the code… any help would be apreciate it!!
Here is what I have done
extends CharacterBody2D
class_name Bird
@export var gravity = 900.0
@export var jump_force = -300
@export var rotation_speed = 2
@onready var animation_player: AnimationPlayer = $AnimationPlayer
var max_speed = 400
var is_started = false
func _ready():
velocity = Vector2.ZERO
func _physics_process(delta):
if Input.is_action_just_pressed(“jump”):
if !is_started:
is_started = true
jump()
if !is_started:
return
velocity.y += gravity * delta
velocity.y = min(velocity.y, max_speed)
move_and_collide(velocity * delta)
rotate_bird
func jump():
velocity.y = jump_force
rotation = deg_to_rad(-30)
func rotate_bird():
if velocity.y > 0 and rad_to_deg(rotation) < 90:
rotation += rotation_speed * deg_to_rad(1)
elif velocity.y < 0 && rad_to_deg(rotation) > -30:
rotation -= rotation_speed * deg_to_rad(1)