Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Anastasia |
Heres the code
extends KinematicBody2D
var motion=Vector2()
const UP =Vector2(0, -1)
const GRAVITY = 100
const SPEED = 1000
const JUMP_HEIGHT = -2500
var state_machine
func _ready():
state_machine = $Node2D/AnimationTree.get("parameters/playback")
func _physics_process(delta):
motion.y +=GRAVITY
pass
if Input.is_action_pressed("ui_right"):
motion.x=SPEED
state_machine.travel("run")
elif Input.is_action_pressed("ui_left"):
motion.x=-SPEED
state_machine.travel("run")
else:
motion.x = 0
state_machine.travel("Idle")
if is_on_floor():
if Input.is_action_just_pressed("ui_up"):
motion.y = JUMP_HEIGHT
else:
state_machine.travel("air")
motion = move_and_slide(motion, UP)
motion = move_and_slide(motion, UP)
point is it travels to “air” instead of "run. its not very visible in the video but take my word
Have you tried putting a breakpoint on the line
state_machine.travel("air")
to see if you hit it while you’re running? Perhaps your character is briefly leaving the ground while running.
Bernard Cloutier | 2020-01-24 15:12
What do you mean by breakpoint?
Anastasia | 2020-01-24 16:54