Hi all,
Is there a way of adding custom properties to GameObjects? Imagine you have a door with a trigger, when a player or an enemy walk into the trigger, the door opens. In the OnTriggerEnter event, I don’t want to check for the tag (enemies are tagged as enemy and the player is tagged as player), but I don’t want to have a lot of “if (isplayer || isenemy){}” in this case it’s just two, but what if there are dogs and cats and a lot of other different gameObjects that can open the door?
Ideally I’d like to be able to set “canOpenDoor = True;” to all those gameObjects and then in the trigger be able to do “if (gameObject.canOpenDoor)”;
Is there a way to do this without having to attach a script to all those gameObjects and then getComponent of to get a reference to that and check if it can open the door?
I’m asking for a general way of achieving this, the door example is just to explain the problem so please no answers like “You can tell the trigger to ignore this and that”.
Thanks