I'm currently stuck. I'm trying to make this character move left and right with different animations for it. However i noticed that when I would try and press the right button it doesn't move. like no animation and doesn't move. It moves left with the animation.
code below_
extends KinematicBody2D
export (int) var speed = 45
onready var animatedSprite = $AnimatedSprite
var velocity = Vector2()
func physicsprocess(delta):
var axisX = Input.getactionstrength("uileft") - Input.getactionstrength("uiright")
if axisX != 0:
animatedSprite.animation = "walk"
else:
animatedSprite.animation = "idle"
get_input()
velocity = move_and_slide(velocity)
func getinput():
if Input.isactionpressed("uiright"):
velocity.x += 1
$AnimatedSprite.play("walk")
if Input.isactionpressed("ui_left"):
velocity.x -= 1
$AnimatedSprite.play("walk")
else:
velocity.x = 0
velocity = velocity.normalized() * speed
$AnimatedSprite.play("idle")