godot

Prevent modulating color of specific child sprites in godot


Updated: I had a hacky way to fix this in the answers below, but @Theraots answer is the proper way to go about it.

I am creating a game with fish.

In order to modularize my project, I decided to make a base Fish scene and use an instance of it for my FishPlayer and School scenes. This way I can simply use a base Fish in other areas in my game.

Base Fish Scene

In my FishPlayer scene, I would like to add color to my fish which I do by using the modulate property in CanvasItem. However, the only problem with this is that it changes the color of the CPUParticles2D of my base Fish scene. The same thing happens as well in the FishSchool scene.

Particles are now orange/brown

So, the end goal here is to keep the original particles color of the base Fish scene while in a new scene allowing color modulation of the rest of the base fish.

I've been messing with the shaders of the CPUParticles in hopes that it would prevent the parent instance from changing it but does not work in my case. Any ideas of what I'm missing here?

Here's a fix that I read about, but didn't work in my case: link


Solution

  • From the context menu of the scene tree on the scene where you instance the fish… Select Editable children. Then you will have access to the child nodes of the fish (while it is still an instance of that scene), so you can use modulate only on the nodes you want, instead of having to use modulate on the root of that scene.