Godot Version
Question
I’m following a tutorial, and can’t seem to get my flappy bird to fall, it shows up but just sits there. In the tutorial the guys bird is already falling with his code (That I thought I followed along to a T, and quadruple checked). Any idea why by chance? Thank you so much in advance. Coding is a blast but I am struggling. Here is my code:
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
var max_speed = 400
func _ready():
velocity = Vector2.ZERO
func _physics_process(delta):
if Input.is_action_just_pressed(“jump”):
jump()
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():
# Rotate downwards when falling
if velocity.y > 0 && rad_to_deg(rotation) < 90:
rotation += rotation_speed * deg_to_rad(1)
#Rotate upwards when rising
elif velocity.y < 0 && rad_to_deg(rotation) > -30:
rotation -= rotation_speed * deg_to_rad(1)