Turn off Mirror on Walkaway


Been working on a SDK3 world and I need some help with my mirrors. I currently have buttons that turn them on and off, but I’d also like them to automatically turn off when a player walks away from them. Could someone help me with that? Thanks!

If you create a box that covers the area you want the mirror to stay active then you can use OnTriggerExit to disable the mirror.

You’ll also need to create a new layer that only collides with players. Edit your layers to create a new one – let’s call it “PlayerTrigger”. Then in your Project Settings under Physics, set your Collision Matrix so that your PlayerTrigger layer only collides with PlayerLocal. From there, set the layer of your box trigger to PlayerTrigger, then make sure that its Box Collider component has “Is Trigger” checked.

In your box trigger, create a script that contains OnTriggerExit either as a graph node or an U# method. Within this method you can modify your mirror’s state similar to the way you did it with the button. If you’re using a state variable for this don’t forget to set that variable public so that you can modify it from the box trigger.

Personally I like to keep track of state and have it stay “on”, that way even when the mirror is disabled it comes right back up when you return without having to press the button again. This is totally up to you however.

Let me know if any of this was unclear or if you need more help!

Thank you, Rorroh! This is very helpful. I think I’ll be able to figure it out from here. Really appreciate your thorough response.

No problem at all! There’s one thing that I forgot to mention just in case. You’ll almost definitely want your box trigger to be invisible. This is as simple as disabling the Mesh Renderer on it.