The Interactive Door System provides an intuitive and powerful solution for crafting highly interactive and responsive door mechanics in Unity. This system offers a range of features to enhance gameplay, including smooth rotation, door types, and an ID system for pairing with keys. With this system, you can create dynamic and immersive experiences for your players.
The Interactive Door System includes the following features:
- Door.cs:
- Smooth Rotation: Uses coroutine to smoothly interpolate between open and closed rotations with adjustable speed.
- Door Types: Supports Trigger, KeyDoor, and Normal door types.
- ID System: doorID for pairing with keys.
- DoorRaycast.cs:
- Raycast Interaction: Casts a ray on E press to detect doors within a specified distance on a designated layer.
- KeyDoor Exclusion: Only interacts with Trigger and Normal door types (ignores KeyDoor).
- DoorTrigger.cs:
- Auto-Trigger: Automatically toggles the target door when a player enters the collider.
- Direct Reference: Requires manual assignment of the target door in the inspector.
- Key.cs:
- Pickup/Drop: PickupKey() hides the key and shows it in hand; DropKey() throws it forward on G press.
- Key-Door Pairing: keyID matches doorID for unlocking.
- KeyRaycast.cs:
- Dual Functionality:
- Pickup Key: Casts a ray on E to pick up keys on a designated layer, disabling physics and showing the key in hand.
- Unlock KeyDoor: Uses the held key on KeyDoor if the doorID matches.
- Drop Mechanic: G drops the key, re-enables physics, and resets its position.
- System Integration:
- Key-Door Logic: KeyDoor only opens if the held key's keyID matches the door's doorID.
- Input Flow: E handles both interaction and key usage; G is dedicated to dropping keys.





