0 votes

3d project
I have two players, using the same material,
One was hit, I made him red,
But because of the same material, when I turn the material red, both players turn red.
I just want to make a player red.
How to do

in Engine by (26 points)

2 Answers

0 votes

You can replace the material with a duplicate.

#I'm assuming that material override is the one you want the instancing to be discarded
material_override = material_override.duplicate()

That .duplicate() is found in all objects inheriting from Resource. It makes a copy of the resource which pretty much discards instancing.

by (3,928 points)
0 votes

Discard instancing is to put all the nodes of an instanced scene in the current edited scene (in editor).

What you see happens because all Resource types are shared by default (same reference) to save system resources.

And to change that you can make the Material resource "local to scene", check your material resource, the option to make it local should be at the bottom on the inspector.
This will duplicate the resource when the scene is instanced (be careful to not use that when not needed).

by (7,934 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.