0 votes

Hi,

First of, sorry if my question seems a little dumb at first, I am basically (re)learning how to code with godot and I am amazed by what it allowed me to achieve with my technical background.

That being said, I am trying to see if I can handle animated 2D Characters, using skeletons and Polygons2D.

So far so good, and the GBot Tutorial is just excellent.

At this point I want to change the skin of my GBot. So I made a variation of the first one (basically it's the same painted all Red) and I would like to load the red skin or the blue skin on given conditions.

e.g. : if my armRight is a polygon2D in a kinematicbody2D, I set the UV with a picture I loaded in the Inspector, but I would like to switch it to another one with code.
Changing the $ArmRight.texture with my new *.png obviously does not work (I had to give it a try :)) despite being the exact same image shape with different colors.

I do not get how to use the set_texture for my polygon2D. Maybe I am just missing how to initiate a texture object but the documentations mentions it cannot be used on its own, so I am a little bit lost.

Any clue on how I could achieve this ?

I could probably duplicate my character scene with a different texture and instantiate it, but there must be a better way...

Many thanks for any advices

Godot version 3.2.3
in Engine by (80 points)

And right after another search session, I fell upon the var texture=load("res://*png") thing that worked wonders with polygon.texture = texture ....^^'

Sorry for the redundant question though !

1 Answer

0 votes
Best answer

And right after another search session, I fell upon the var texture=load("res://*png") thing that worked wonders with polygon.texture = texture ....^^'

Sorry for the redundant question though !

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