Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | K1ngK0ng |
This is my script
extends KinematicBody2D
export (int) var speed = 200
var velocity = Vector2.ZERO
var state_machine
func _ready():
state_machine = $AnimationTree.get(“parameters/playback”)
func get_input():
var current = state_machine.get_current_node()
velocity = Vector2.ZERO
if Input.is_action_pressed(“right”):
velocity.x += 1
state_machine.travel(“RunRight”)
if Input.is_action_pressed(“left”):
velocity.x -= 1
state_machine.travel(“RunLeft”)
if Input.is_action_pressed(“up”):
velocity.y -= 1
state_machine.travel(“RunUp”)
if Input.is_action_pressed(“down”):
velocity.y += 1
state_machine.travel(“RunDown”)
if velocity.length() == 0:
state_machine.travel(“IdleDown”)
func _physics_process(delta):
get_input()
velocity = move_and_slide(velocity)
Are you receiving any error messages? Also, have you checked to make sure the input map is set up properly?
figroot | 2021-11-04 18:18