Почему эта переменная постоянно меняется на false в gdscript? - PullRequest
0 голосов
/ 29 октября 2019

Я пытаюсь заставить этот сценарий успокоиться. Когда игрок прыгает, он должен сделать землю и начать движение, а не останавливаться. Но он движется только тогда, когда игрок прыгает.

Мой код:

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)

Прыжок ложен в половину времени и истинен для другой половины.

...