Sensor based door open/close unity tutorial | Slide door using sensor in unity3d

Subscribers:
1,110
Published on ● Video Link: https://www.youtube.com/watch?v=o07xCwByV0Y



Category:
Tutorial
Duration: 4:44
17 views
4


ASSALAM o alaikum In this video we have shown how to open a door using slide on sensing if anything is near it

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

public class DoorManager : MonoBehaviour
{
public Transform player;
public float currentDistance, minimumDistance;
bool doorOpen;

// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
currentDistance = Vector3.Distance(player.position,transform.position);

if (currentDistance greater than sign =minimumDistance && !doorOpen)
{
doorOpen = true;
GetComponent less than sign Animator greater than sign ().Play("DoorOpen");
}

else if (currentDistance greater than signminimumDistance && doorOpen)
{
doorOpen = false;
GetComponent less than sign Animator greater than sign ().Play("DoorClose");
}
}
}

/*
/////////////////////////////////////////////////////////////////////////////////////////////
ASSALAM o alaikum
All codes and concepts and videos from this channel are non copyrighted and free to use because we believe that knowledge should be freely available for everyone
/////////////////////////////////////////////////////////////////////////////////////////////
*/







Tags:
unity
unity3d
learn unity
unity tutorials
sliding door in unity
sensor based door openeing in unity
Slide door using sensor in unity3d
Sensor based door open/close unity tutorial