I'm trying to make this script make the ground still. When the player jumps it is supposed to make the ground and start moving and not stop. But, it is only moving when the player jumps.
My Code:
extends Area2D
#Script-Purpose: move and delete ground
#Ground moving speed
const SPEED = -150
#a vector2 to change the speed of the ground
var velocity = Vector2()
#to check if you have jumped yet
var Jumped=false
#calls Physics
func _physics_process(delta):
#left-click=jump
if Input.is_action_pressed("ui_jump"):
Jumped=true
#make the velocity.x equal to speed accounted with delta time
if Jumped==true:
print(Jumped)
velocity.x = SPEED * delta
translate(velocity)
else:
#this is here so I can check if the Jumped var is false
print(Jumped)
Jumped is false half the time and true for the other half.