0 votes

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)

Heres a video

point is it travels to "air" instead of "run. its not very visible in the video but take my word

in Projects by (63 points)
edited by

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.

What do you mean by breakpoint?

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 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 webmaster@godotengine.org with your username.

Categories