godot - 为什么这个变量在 gdscript 中不断变为 false?
问题描述
我正试图让这个脚本保持原状。当玩家跳跃时,它应该是地面并开始移动而不是停止。但是,它只有在玩家跳跃时才会移动。
我的代码:
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 有一半是假的,另一半是真的。
解决方案
推荐阅读
- continuous-integration - 如何为 CI/CD 管道安装 Cypress
- angular - 根据状态更改内容
- html - 单行中的链接和简单表单
- html - 无法在较小的屏幕上更改图像位置
- python - 在没有 AWS 访问密钥的情况下部署烧瓶应用程序
- mysql - 表被指定了两次,都作为“更新”的目标
- python - Selenium--Python 没有从 Tkinter 条目小部件中获取输入--TypeError:“函数”类型的对象没有 len()
- python - 无法使用子进程 Python Windows 10 发送输入参数值
- sql - 在 SQL 中使用 where 子句
- javascript - 清除钩子上的异步调用-React Native/Firebase 我该怎么做?