Unity Engine - Physics Based Door Project

Опубликовано: 02 Июль 2026
на канале: Nicholas Niles
115
4

This is a tiny demo I put together using my first person controller I developed previously. It is a completely physics based door that interacts with everything and snaps off the hinges with enough force. It starts as locked, and when the player left clicks it unlocks and applies a pushing force based on the players Vector3.forward at the time of the click and multiplies it by the player's pushForce which is a variable under the player script. It uses a raycast to check the distance from the camera to whatever the player is looking at, and if that is less than 5 and the raycast collides with either a gameObject with the Door script or Pushable tag, it will interact accordingly, unlocking an object with the door script and pushing an object with the Pushable tag.