So i want to check if a door is locked depending on if there is a lock infront of it or not. the door has a trigger area for where the lock is but my question is how do i detect the lock in code? I think it should be a OnTriggerStay since it will be unlocked when the lock is destroyed.
well i want to detect if a certain gameobject (the lock) is within the trigger zone of another gameobject (the door).
ok i made a simplified version of the scenario. If you beat the first block the second blocks lock is destroyed. i want to detect if the lock is in the trigger zone and if it isn’t it will do something. I know there might be a better way of detecting if the level is beat but i want to try this version. I don’t really know what else to add. I just want to know what line of code would work for this.
Well if you need the lock as a separate object, you have to add rigidbody and collider to it, so it triggers the event. But what i would personally do, is to make the lock part of the Door prefab, give the door script boolean “locked” and on changes of this variable i would enable/disable the lock in hiearchy, so it hides when unlocked.