How to Open a Door With a Key

The Creator’s most basic tutorial!

This tutorial is basic because of its simplicity. If you need an open door script for your project, this video is made for you! It has not too much to talk about, because you can create a simple cylinder. That will act like a key object.

Click the video to watch.

In this video, you will learn how to make a door openable by collecting a key object, which can be something other, like a cylinder or a cube. The door will be animated every time the player approaches it. The door will only work if the player collects the key. To open a door in Unity, you need to collect a key. You need to create a simple cylinder object (or any other) and possibly assign a material with the color (as you like).

Then you have to resize it to the size that is slightly smaller than the player. Unlike the previous tutorial, this time you need to only add a script to the key object, which is pretty straightforward. Add a simple script that will open the door once the key is collected. Don’t destroy the key before opening the door! Put that line of code at the last part of the brackets.

Then a nice little animation should play after the key is collected. The game should continue and the new part of the level can easily open. You can now say that the game is working smoothly.

There is also a video that describes the basics of the door opening animations. If you haven’t previously watched the latest video, this video is made for you.

Previous tutorial is here:

Click the video to watch.

Leave a Reply

Your email address will not be published. Required fields are marked *