![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | BakouKai |
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
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 !
BakouKai | 2021-03-20 16:30