proobléme pour faire sauter mon personnage

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By louischav

voici mon code si quelq’un veut m’aider, merci d’avance
extends KinematicBody2D

constante

const GRAVITY = 1500
const SPEED = 400
const JUMP_FORCE = -1000
const FLOOR_NORMAL = Vector2(0, -1)

#pour le déplacement du personnage (direction)
var motion = Vector2()

func _physics_process(delta):
jump()
gravity(delta)
walk()
move_and_slide(motion, FLOOR_NORMAL)
func walk():
#si on appuie sur la droite ou d
if Input.is_action_pressed(“ui_right”):
$“animated sprite”.flip_h = false
$“animated sprite”.play(“walk”)
motion.x = SPEED
elif Input.is_action_pressed(“ui_left”):
$“animated sprite”.flip_h = true
$“animated sprite”.play(“walk”)
motion.x = -SPEED
else:
motion.x = 0
$“animated sprite”.play(“idle”)
func gravity(delta):
if is_on_floor():
motion.y = 0
else:
motion.y += GRAVITY * delta
func jump():
if is_on_floor() and Input.is_action_pressed(“jump”):
motion.y = JUMP_FORCE
if motion.y < 0:
$“animated sprite”.play(“jump”)

This is an English-speaking questions and answers platform. Please ask questions in English :slight_smile:

Calinou | 2020-12-28 02:02