0 votes

I have a running animation and an idle animation for a 'player' sprite. They are two different png spritesheets. If I wanted the player to run, how would I change the texture in the player sprite to the different spritesheet? I tried to keyframe the texture and HFrames at the start of the animation but that didn't work.

in Engine by (35 points)

1 Answer

+2 votes
Best answer

You can call a function to change the spritesheet and set set hframes

Something like:

func load_spritesheet(file, hframes):
    sprite_node.set_texture(load("res://path/to/" + file))
    sprite_node.set_hframes(hframes)
    [etc]
by (486 points)
selected by
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 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 webmaster@godotengine.org with your username.