Remote controlled door

I had an idea for a remote controlled door. So, I created an object with a script to interact with a door object using a serialized field to assign which door this should be in the inspector. Pretty simple, works great.

The issue is that the player can still interact with the door I’m not sure how to go about modifying the Door/InteractAction scripts to create a door that can be interacted with by the remote, but not ‘detected’ by the interact action of a unit. Would the solution be to simply create a brand new object that is not an interface/IInteractable?

Yes. The door itself should not be interactable, because you don’t want it to be interactable. The interactable for this is the remote only. So, you may have two types of doors; Doors that are directly interactable and doors that are remote controlled

I hear ya. Usually, I like to go with the K.I.S.S. approach when I find a problem but ya never know. I’d actually already done that (created a new type of object), but was mostly just curious. Anyways, thanks for the tip, as usual.

1 Like

Yep, the simplest approach. Attempting to add functionality (like a [SerializeField] bool notReallyInteractable;) on the Door script could work, but would add more complexity that simply isn’t needed. I would have an InteractableDoor : MonoBehaviour, IInteractable and a RemoteControlledDoor : MonoBehaviour. This clearly documents the function of the two scripts (without even needing to comment it!) and clearly separates the two interaction types.

Hello again, Brian

Yea, I experimented a little bit with something like that (the serialized field) but had somewhat limited results and I was finding that I was going down a bit of a rabbit hole of having to change things

While it can be done, it’s added complexity that can lead to unintended bugs.

Privacy & Terms