我正在尝试使此脚本保持稳定。当玩家跳跃时,应该让其开始并开始移动而不停止。但是,只有当玩家跳跃时它才会移动。
我的代码:
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)
跳跃的时间一半是错误的,另一半是真实的。