|Topic was automatically imported from the old Question2Answer platform.
I would like to use a specific node of a different instance within another seperate node, but don’t really know how to go about doing it properly. The following statement I have resolved to use seems “hacky” and would love to hear a proper solution:
The reason I am trying to do this is because I have multiple colour variations of the same sprite. And for each colour variation, a version of all animations associated with it (The animation is the same for all of them with the only difference being the colour of the sprite). I have separated any node data relating to each colour variation (AnimatedSprite Nodes) into separate instances (scene files), and would like to “import” whatever node data is necessary for the colour I choose to select within a separate script.
I think my question stems from a lack of understanding as to how GDScripts and Nodes relate to one-another, as well as to how to effectively use them together.
This is my first game with Godot, so I’m still trying to get my bearings with how to develop a game within the engine, as well as developing games in general.
Any help and suggestions would be definitely appreciated!
Looking around the docs have helped clarify the relation of the script and the node. Though the question still stands really.
dracut | 2018-12-12 10:56
Why would you need to have duplicates of the same animation if the only difference is colour?
SIsilicon | 2018-12-12 13:33
Honestly I don’t know how to programmatically do it within Godot so this is how I’ve been logically doing it until I figure that out. I’m open to alternatives. If I could change the colour of the resource image that would be fantastic. I’d just use one sprite and change the colour.
dracut | 2018-12-13 04:16
There should be a modulate feature on sprites which will change the overlay color of the sprite. Not sure if you want different colored shirts though since the modulate affects the whole sprite I believe. You could have different textures for each color (copy the same sprite sheet and change the color of the shirts or pants) then write in your script to change between the sprite sheets when you need to change the color.
CensedPie | 2018-12-13 08:44
If you need to change colors a lot and don’t have a set color variation aka red, purple, blue, yellow teams and want something more like a RGB range, you can separate the parts you need to change color from the main sprite. Example: You want to change the shirt color only on the sprite, make a sprite sheet with the character excluding the shirt area, make a sprite sheet with just the shirt, have 2 sprite nodes, modulate the shirt sprite node to whatever color you want using the modulate property.
CensedPie | 2018-12-13 08:49
This is actually great. The sprites I am using are of two colours, super simple. I have 5 different colour variations one of which is white. Modulating on the white sprite allows
me to represent the other colours. Thanks a lot for the suggestion! Makes this question moot.
dracut | 2018-12-13 15:01