![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | FaarisAnimDev |
Jump script is not working please help
script: extends KinematicBody2D
export var velocity = Vector2.ZERO
export var speed = Vector2(300.0,300.0)
export var gravity = 300.0
var Accel = 10
const UP = Vector2(0, -100)
const JUMP = -10
func _process(delta: float) → void:
if Input.is_action_pressed("ui_right"):
velocity.x += gravity * delta
velocity.x = max(velocity.x , speed.x)
if Input.is_action_just_released("ui_right"):
velocity.x = 0
if Input.is_action_pressed("ui_left"):
velocity.x -= gravity * delta
if Input.is_action_just_released("ui_left"):
velocity.x = 0
func _physics_process(delta: float) → void:
velocity.y = gravity
if Input.is_action_just_pressed(“ui_up”):
velocity.y = -25
velocity = move_and_slide(velocity,UP)
You should use func _input
clemens.tolboom | 2021-07-25 16:59