This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I have a 2.5D side-view game in which you enter a building and only the room you are in is visible, and every other room is covered with simple CSGBox mesh with black material like this:
enter image description here

Logic is simple, every room has it's own area with:

func _on_RoomArea_body_entered(body):
    blackFade.visible = false

func _on_RoomArea_body_exited(body):
    blackFade.visible = true

So if I go from Room 4 to Room 1, the logic in Room 4 will turn visible to true for itself, and Room 1 logic will turn visible false for itself.

And it works but it's not clean since it just pops in and out. I wanted to play FadeIn and FadeOut animation through AnimationPlayer but the problem is: Every CSGBox uses the same material so if I change alpha for one, it changes for all of it. The easy solution is to make unique material for each black panel, but that's a lot of unique materials, what if there are 100 rooms, that's 100 unique materials that will change only alpa and the rest stays the same. So is there a way to modify a property (albedo -> alpha) for the material without making it unique and have hundreds of duplicates?

Godot version 3.5.1.stable
in Engine by (62 points)

1 Answer

+1 vote
Best answer

If You want to animate materials property, which cannot be shared by all instances - there is no other way. You don't really have to make_unique, You can just set local_to_the_scene property for parent scene in editor to true. I doubt this will cost much of a framerate though, since they will be invisible most of the time. If You really need to optimize this, I guess You could eventually set unique materials only for the rooms player is currently relocating, until they are animated, and than just change all invisible rooms materials to shared one.

by (8,188 points)
selected by
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.