Ok, so I’ve been making a horror game recently, and I’m stuck on making a hiding system. I’ve been searching for a good tutorial on how to make a system that allows the player to interact with a wardrobe or locker, and then puts them inside of it. I have no idea how I would make that aside from making a script that detects when the player interacts with a gameobject and teleports them inside of it. My only problem is that I have very little coding experience, so if anyone has suggestions, I would be really happy. Edit - I should mention that my game is a first person 3D game.
Sounds similar to interacting with any door. I would search Youtube to figure out how to create interactive doors in Unity. You’ll get a lot of tutorials that use animator components to make the doors open/close. Personally, I prefer to animate doors procedurally so that I can just assign a value from 0-1 to represent fully-open vs. fully-closed.
If your door is procedural, you can use hand IK (inverse kinematics) if you want your character to reach out and grab the door to open/close it. Final IK is a popular plugin on the Asset Store, but there are a dozen IK frameworks to choose from. There may not be any tutorials specifically about IK for interaction with a door, but there are lots of IK tutorials for interacting with a player’s hand touching a wall. The concept will carry over.
Once you can animate a door object procedurally (and I suggest rigging it to a slider in Inspector for easy testing), and you can use IK to animate player’s hand to grab the knob, you can script the door opening with a tween function. Then you’ll need to create a special crouching animation if the hiding place is too small to walk into. From inside, you could try the same procedural door-swing-plus-hand-IK technique from inside, but it’s probably better to just tween the door closed as they enter.
For tweening capability, if you’re not familiar with Quaternion.Lerp() or coroutines, I would use this as an opportunity to practice those if you want to level up your coding. However, it’s more common for games in production to use a tweening plugin. DoTween is the most popular one on the Asset Store, but there are many others.