0 votes

so i have two animation in one scene but i cannot change animation to another animation
i mean i want when a button (screen) pressed the want to be changed to another animation

here is my code

extends TextureButton 
onready var anim = get_node("AnimationPlayer")

##i connected to button node (presssed)##
func _on_TextureButton_pressed():
   anim.current_animation("starting")

If you don't understand sorry i am very poor at explanation.if you have a question tell me

in Engine by (21 points)
edited by

1 Answer

0 votes

the function current_animation returns the current animation but if you want to start a animation use anim.play(animation name: string)

by (290 points)

Hey mdubalsl i have done it what you said but unfortunately it doesn't work

here's the code again!,

extends TextureButton

onready var anim = get_node("AnimationPlayer")

##i connected to button node (presssed)##
func _on_TextureButton_pressed():
    anim.play("starting")

The code now appears correct, your problem is likely elsewhere. Signal is not connected to that function, no animation keyframes, etc.

hey avencherus sorry for late response and also i am extremely sorry i check the signal it but it connect and i again reconnect it but the answer is no. i have done research about it and found something weird .you know when Godot is opening a console will also opened so ummmmm when i run (game) i can see ERROR: Node not found: AnimationPlayer.
in the console but i can seeAnimationPlayer on the project is this a bug or something?

If you believe it to be a bug, then consider submitting a bug report with a minimal project showing the problem: https://github.com/godotengine/godot/issues

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.