0 votes

Had to redo the project I was working on and now it refuses to let me jump. I've been going over the code for hours now but I can't seem to find what's wrong. GoDot isn't even giving me any error

func _physics_process(_delta: float) -> void: var is_jump_interrupted: = Input.is_action_just_released("jump") and _velocity.y < 0.0 var direction: = get_direction() _velocity = calculate_move_velocity(_velocity, direction, speed, is_jump_interrupted) _velocity = move_and_slide(_velocity, FLOOR_NORMAL)

func get_direction() -> Vector2: return Vector2( Input.get_action_strength ("move_right") - Input.get_action_strength ("move_left"), -1.0 if Input.is_action_just_pressed("jump") and is_on_floor() else 1.0 )

func calculate_move_velocity( linear_velocity: Vector2, direction: Vector2, speed: Vector2, is_jump_interrupted: bool ) -> Vector2:

var out: = linear_velocity
out.x = speed.x * direction.x
out.y += gravity * get_physics_process_delta_time()
if direction.y == -1.0:
    out.y =  speed.y * direction.y
if is_jump_interrupted:
    out.y = 0.0
return out
Godot version Version 3.5.1
in Engine by (15 points)

I ran your code and it jumps fine. Can I see how you defined the variables in the script?

code symbols are bugging out

extends KinematicBody2D
class_name Actor

const FLOOR_NORMAL: = Vector2.UP
export var speed: = Vector2(300.0, 1000.0)
export var gravity: = 4000.0

var _velocity: = Vector2.ZERO

func _physics_process(delta: float) -> void:
_velocity.y += gravity * delta
_velocity =  move_and_slide(_velocity)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.