How to Make Basic Doors in Unity - Unity C# Tutorial

Channel:
Subscribers:
8,690
Published on ● Video Link: https://www.youtube.com/watch?v=dgLF-37SBDk



Duration: 8:10
5,480 views
0


In this Unity tutorial, I teach you guys how to make basic doors in Unity 3D. We'll also be making use of the C# programming language for this tutorial.

#Unity #Unity3D #GameDevelopment

For more Unity C# tutorials - be sure to like, comment, and subscribe for more! 👍

Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Door : MonoBehaviour
{
public GameObject doorClosed, doorOpened, intIcon;
public float openTime;

void OnTriggerStay(Collider other){
if(other.CompareTag("MainCamera")){
intIcon.SetActive(true);
if(Input.GetKeyDown(KeyCode.E)){
intIcon.SetActive(false);
doorClosed.SetActive(false);
doorOpened.SetActive(true);
StartCoroutine(closeDoor());
}
}
}
IEnumerator closeDoor(){
yield return new WaitForSeconds(openTime);
doorOpened.SetActive(false);
doorClosed.SetActive(true);
}
void OnTriggerExit(Collider other){
if(other.CompareTag("MainCamera")){
intIcon.SetActive(false);
}
}
}


Follow me on Twitter:
https://twitter.com/omogonix

Try out my games:
https://omogonixlachlan.itch.io

Forgehub:
https://www.forgehub.com/members/omogonix.87700/

Subscribe to my Second Channel:
https://www.youtube.com/channel/UCkylkvUtpvbHfafGfIdMLBQ/featured

Join my Discord:
https://discord.gg/a88vmGD

Facebook Page:
https://www.facebook.com/Omogonix/

Follow me on Instagram:
https://www.instagram.com/uwugonixhalo/







Tags:
unity
unity 3d
unity tutorial
how to
how to make
unity door tutorial
how to make doors in unity
unity beginners
unity beginners tutorial
c#
csharp
how to use c#
c# tutorial
csharp tutorial
game development
how to make a game
how to make a game in unity
omogonix
tutorial
programming