extends CharacterBody2D
const SPEED = 300.0
const JUMP_VELOCITY = -300.0
var timer: float = 0
# Curve movement variables
var t = 0.0 # interpolation factor along the curve (0 to 1)
var curve_speed = 1.0 # speed along the curve
var following_curve = false
func _ready() -> void:
GlobalVariables._player_hit_pipe.connect(_player_hit_pipe)
func _physics_process(delta: float) -> void:
if GlobalVariables.lost:
position = $Path2D/PathFollow2D.position
else:
# Normal gameplay
velocity.y += 500 * delta
timer -= delta
if timer <= 0 and Input.is_action_pressed("ui_accept"):
velocity.y = JUMP_VELOCITY
timer = 0.5
move_and_slide()
func _player_hit_pipe():
GlobalVariables.lost = true
timer = 0.1
So i'm trying to set up a bezier curve for my flappy bird player when he get hit by a pipe but this happens (see gif).
I have also have my nodes hierarchy in my images...
This is my PathFollow2D's script.
extends PathFollow2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
GlobalVariables._player_hit_pipe.connect(_player_hit_pipe)
func _player_hit_pipe():
set_progress_ratio(0.1)
If my question isn't clear enough, please feel free to say so and I'll rehearse my question. I'm already afraid enough that what I'm asking help for isn't comprehensible I think