- Home /
open and close door
this script opens door and closes automatically can you please write a script for me that open and closes only when player collides with the door
my script
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Door : MonoBehaviour { public Animator animator;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter(Collider other)
{
if (other.tag == ("Player"))
{
animator.SetBool("isopen", true);
}
}
private void OnTriggerExit(Collider other)
{
animator.SetBool("isopen", false);
}
}
Comment
Your answer
Follow this Question
Related Questions
Door will not open with the press of a button 1 Answer
Simple Script - and no result 2 Answers
Script for a door that opens and closes help! 1 Answer