2d Fog of War - How to do it efficiently?

Hey folks,

I’m currently looking into how to do 2d Fog of War, Terraria style:

My initial implementation looks like this: I have tons of little planes scattered throughout the world. Since I only know how to use triggers if they have a Box Collider as well as a rigidbody assigned to them, that’s what I did. Now the code works like:

If SightTrigger enters, set materialColor to X. If sightTrigger exits, set it back to black.

Now, this works, but it’s not very efficient and just rapes the performance, since I literally have around 100 gameobjects just there, all with box collider and rigidbodies applied to them.

Is there a clever way of how to do this implementation without any heavy calculation?

A trigger does not need a rigidbody to work, just a collider. Unless you need the rigidbodies for other purposes, remove them - the physics engine must make a lot of calculations for each rigidbody, which certainly impacts performance. Try to remove a few rigidbodies and check if your game still works fine, then remove all of them if they are not really needed.