The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+1 vote

Flipping a sprite on its y axis is fine when its symmetrical but when it comes to something that is asymmetrical it just doesnt add up. Example sprite holding sword and shield. Flipping will not show the sword and shield in the correct hands. What I came up with is this.

I put two sprites under the parent player node, one showing it facing left and one facing right. When hitting right input I use hide() on the left one and than show() on the right one, when hitting left input vice versa. This essentially means that I'll have to have to double the amount of animations and call them appropriately based on input. For one test image this is fine but something tells me later on as a game grows more complex this could get hairy. Is this method fine or there a better alternative using the godot engine?

One possible idea I had was having the armaments whatever they are as separate objects that would change positions based on direction. This would mean less images to load at start but I also foresee some annoying bugs with that popping up.

Another thought I had was to load and delete the sprites dynamically, but I'm most likely over complicating this by doing so. Something tells me there a very simple way to pull this off that I'm just not seeing in my limited experience with this engine.

I'd be interested in hearing the communities thoughts on this.

in Engine by (58 points)

2 Answers

+1 vote
Best answer

What kind of animation are you using? If you are using sprite sheets you can just add another animation that accesses other parts of the sheet, thus allowing you to put all animations on one sheet.

by (1,124 points)
selected by

I was going to use bones and ik on a cutout. I see what you mean, using a spritesheet would be preferable that way gpu would just load one large image once instead of referencing multiple and I can just declare a different region of the same image for each part. I just did this by using this in the script on my RidigBody2d:

#global var
var sprite_mod = null
#in _ready() so I can use sprite classes in ridigbody2d extend
sprite_mod = get_node("name_of_sprite")
#position of each region inside each correct if input statement
sprite_mod.set_region_rect(Rect2(x,y,w,h))

Thanks =) I tend to over complicate stuff.

0 votes

I used the code of the platformer example:

set_scale(Vector2(-1, 1))

and

set_scale(Vector2(1, 1))

for other direction.

by (26 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.