Misaki Its hard at this moment to show all the code, because I have splitted but i try to change animation in one script:
func animate_chicken(velocity):
match(status.gameplay):
status.IN_GAME_CURSOR:
status.animation = status.IDLE
if get_name_animation(0) != "Sigth":
play("Sigth",true,0)
status.IN_GAME:
var act_vel = velocity
act_vel.y = 0
if act_vel == Vector3.ZERO and ray1.is_colliding() and ray2.is_colliding():
if status.animation != status.CROUCH:
status.animation = status.CROUCH
current_animation = play("Sigth",true,0)
elif !chicken.is_on_floor():
if status.animation != status.JUMP :
status.animation = status.JUMP
current_animation = play("jump",true,0)
if movement.mouse_side==1 and chicken.velocity.x>0 || movement.mouse_side==-1 and chicken.velocity.x<0:
current_animation.set_reverse(false)
else:
current_animation.set_reverse(true)
elif spine.preview_animation == "shot":
pass
elif act_vel != Vector3.ZERO && status.animation != status.RUN:
if status.animation == status.JUMP:
current_animation.set_time_scale(2)
else:
status.animation = status.RUN
current_animation = play("run",true,0)
set_time_scale(1)
var dire = -1 if chicken.velocity.x<0 else 1
set_animation_direction(dire,movement.mouse_side)
elif act_vel == Vector3.ZERO && status.animation != status.IDLE:
status.animation = status.IDLE
play("idle",true,0)
Its how i change the animations. This how function play() works:
func play(animation_name:String,looping:bool,track:int):
var animation = spine.get_animation_state().set_animation(animation_name,looping,track)
if !looping:
spine.get_animation_state().add_empty_animation(track,0.2,0)
return animation
And in another script i just run shoot animation:
animation.play("shot",false,1)