Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | LlamasEmperor |
enter code hereI have a problem (and my inglish is not my native language and so my bad grammar), i don’t know how to make my character move and jump at the same time, i tried everything but i don’t know where is my problem.
extends KinematicBody2D
export var GRAVITY = 500
export var Vel_H = 250
export var max_vel = 500
export var vel_Jump = 75
var Velocity = Vector2()
var animator_player
var Jump = false
func _ready():
set_physics_process(true)
Velocidad.x = 0
Velocidad.y = 0
animator_player = get_node("AnimationPlayer")
func _physics_process(delta):
###########Gravity#############
Velocity.y += GRAVITY * delta
###########procesa teclas############
if(Input.is_action_pressed("mov_izq")):
Velocity.x -= Vel_H
if(!animator_player.is_playing()):
animator_player.play("Mover")
get_node("spr_Mario").set_flip_h(true)
elif(Input.is_action_pressed("mov_der")):
Velocity.x += Vel_H
if(!animator_player.is_playing()):
animator_player.play("Mover")
get_node("spr_Mario").set_flip_h(false)
else:
Velocity.x = 0
animator_player.stop()
#######Jumpping###########
if is_on_floor() and Input.is_action_pressed("salto"):
Velocity.y = -vel_Jump
##########Aproxima velocidad maxima###########
Velocity.x = clamp(Velocity.x, -max_vel, max_vel)
##########Mueve###############
var move = Velocity * delta
##########Ajuste de deslizamiento#############
move_and_slide(move, Vector2(0, -1))
if(is_on_floor()):
Jump = false
Hi, I have a problem and I don’t have idea how to solve it. Sometimes when the player is walking and I press space for jump, It doesn’t jump.
Manuel Lucero | 2020-08-22 19:38
But if the character is not moving, the jump works perfectly.
Manuel Lucero | 2020-08-22 19:38