How to make an animation per button-click

ContainerContainer Posts: 57Member

Can someone write me a godot scene, where animation plays, when the button is clicked?

Comments

  • TwistedTwiglegTwistedTwigleg Posts: 4,277Admin

    Well, I would highly recommend going through some Godot tutorials and other learning material, as getting help without knowing how it works isn't that helpful in the long run, but to answer your question: You just need to connect the pressed signal from a Button node to a script, and then in that script have the function tell an AnimationPlayer node to play. Something like this (untested, super simple example):

    extends Node
    
    func _ready():
        get_node("Button_Here").connect("pressed", self, "on_button_pressed")
    func on_button_pressed():
        get_node("AnimationPlayer_Here").play("Animation_Name_Here")
    
  • ContainerContainer Posts: 57Member

    do you recommend a tutorial?
    I don't know where to start

  • TwistedTwiglegTwistedTwigleg Posts: 4,277Admin

    I would recommend reading through the Step-by-step section of the Godot documentation if you already have some programming and game development experience, as it can help get you up to speed on Godot specific things and how common stuff is done in Godot.

    I have heard that GDQuest, HeartBeast, KidsCanCode, and other popular Godot tutorial makers are great for beginners. I have not personally gone through much of their material, but I've been using Godot for years now, so I'm not sure what beginner material to recommend other than I have heard good things about the makers I mentioned. Others may have better recommendations.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file