Camera and enemies

Hi,

I’m trying to build the camera in such a way that you are not able to see enemy units and buildings unless one of your units or buildings is nearby, like in many RTS.

I was trying to achieve this by changing the cullingMask through code for when the camera did not have any nearby units or buildings with authority, but as you may have guessed, both enemies and player units/buildings share the same layer, so when I change the cullingMask, I cannot see my units as well, which is not a huge problem since as soon as the camera is in range with friendly units/buildings, it changes the cullingMask again so that they get rendered.

So, what I’m looking for is to know if there is a better way to do this without having my own units and buildings affected.

Many thanks for the help.

Hi there,
The system I have used in the past is to enabled and disable the renderer for each unit, based on if they should be visible.
Alternatively, you could have a static cullingMask, but modify the layer of the unit based on if it should be visible.
Hope this helps!

1 Like

Hi,

Thank you for the answer. Yes, I think enabling and disabling the renderer method could be more efficient than the cullingMask. I will give it a go. Thank you for your help.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms