0 votes

My Idle seems to override my Attack so it only plays the first frame this is my code

extends KinematicBody2D

var statemachine
var run
speed = 200
var attacks = ["attack1", "attack2"]
var velocity = Vector2.ZERO
var is_attacking

func ready():
state
machine = $AnimationTree.get("parameters/playback")

func attack():
is
attacking = state_machine.travel("attack")

func getinput():
var current = state
machine.getcurrentnode()
velocity = Vector2.ZERO
if Input.isactionjustpressed("attack"):
state
machine.travel("attack")
return
isattacking = true
if Input.is
actionpressed("jump"):
state
machine.travel("Jump")
if Input.isactionpressed("left"):
velocity.x -= 1
statemachine.travel("Run")
$Sprite.scale.x = -1
if Input.is
actionpressed("right"):
velocity.x += 1
state
machine.travel("Run")
$Sprite.scale.x = 1
if velocity.length() == 0:
state_machine.travel("Idle")

func physicsprocess(delta):
get
input()
velocity = velocity.normalized() * runspeed
velocity = move
and_slide(velocity)

Godot version latest
in Engine by (27 points)

Use an actionjustpressed for the attack
and for the animation to play, use another code the same but with actionpressed
What happens is that when you call action
justpressed, what you do is that only when you press atak, only that instant is reproduced.
and action
pressed is so that if the key is held pressed, it will play the animation if the key is pressed
basically just pressed lasts a frame and pressed lasts until the key is released

I hope it helps you since I do not speak English and it is difficult for me to fully understand your question grettings!

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 Frequently asked questions and 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 [email protected] with your username.