Godot Version
4.2
Question
Hello I’m trying to setup the 2nd attack in my run attack chain but the animation won’t play and I can’t really figure out why, any help would be appreciated
attack Code:
AnimationTree:
4.2
Hello I’m trying to setup the 2nd attack in my run attack chain but the animation won’t play and I can’t really figure out why, any help would be appreciated
attack Code:
AnimationTree:
i assume the travel call gets overwritten by the if-else statement in the state_process-method. You have to stop it from traveling while your runattack2 animation is playing. do you have a enter_state-method?
i can give you the ugly solution (which is the easiest to insert), but if you are interested i can give you a better solution.
change your code to the following:
var attack1: bool = false
func state_process(delta):
print(playback.get_current_node())
if attack1:
return
attack1 = true
...
func _on_animation_tree_animation_finished(anim_name):
if(anim_name == "RunAttack") and attacked:
playback.travel("RunAttack2")
else:
attack1 = false
next_state = groundState
if anim_name == "Attack" or anim_name == "RunAttack2":
attack1 = false
next_state = ground_state
Im slightly confused about this implementation as you set attack1 in the delta process won’t it always be true then?
Ill try implement this tomorrow but I would be interested in the better implementation if you have the time, thanks!
the better solution depends on your state-machine implementation. can you copy the state-machine here?
The reason this should work is, because in the first call of state-process attack1 is set to false so it basically gets called only once
Ah I get you, it exits state process on attack1 being true.
here is my state class code:
Here’s my character State machine code:
so you do have a on_enter and on_exit-method. Good.
Just put the code from state_process in the on-enter-method of AttackState and remove everything i changed
ok will try thank you
ok I’m pretty sure this will work, its just something is currently overriding my attack animations now, so once I figure that out it should be good
got it working thanks a lot
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.