0 votes

Hi! I am new to coding and everything and I am currently making a GoDot 2D game, Its mostly mazes but I have a character select in where I want to make it so that If I click a button it will CHANGE my player sprite to that image for other scenes aka the other lvls

Godot version 3.2
in Engine by (12 points)

you could decouple your player node to your scene levels.

Rather than:

Root

Level01(Node2D)

Player(KinematicBody2D)

You could have a game manager that manages the state of your player outside of the levels.

Root

GameManager(Node)

Level01(Node2D)

Player(KinematicBody2D)

Then your game manager handles spawning your scenes/levels and your player, and other entities.

Although of course, you could have a Global singleton that will hold information of your player sprite.

see: https://docs.godotengine.org/en/stable/getting_started/step_by_step/singletons_autoload.html

You can also use the AnimatedSprite node in which you can define different animations with different sprites.

Then you'll only need to call the play function on your animated sprite with the name of your sprite/animation you want to use.

1 Answer

0 votes

Like Szesan said, use Animated Sprite and then if you input a button, change it's frame to whatever you like

by (385 points)
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.