forked from Myyyvothrr/1gam-dungeon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
door.cs
42 lines (35 loc) · 799 Bytes
/
door.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using UnityEngine;
using System.Collections;
public class door : MonoBehaviour
{
private GameObject _left;
private GameObject _right;
private bool _opened = false;
void Start()
{
_left = transform.Find("door_left").gameObject;
_right = transform.Find("door_right").gameObject;
}
void Update ()
{
}
void open()
{
_left.animation.Play();
_right.animation.Play();
_opened = true;
}
void OnTriggerEnter(Collider other)
{
if (!_opened && other.gameObject.tag.Equals("Player"))
{
other.gameObject.SendMessage("update_near_door", true);
other.gameObject.SendMessage("set_near_door", gameObject);
}
}
void OnTriggerExit(Collider other)
{
if (other.gameObject.tag.Equals("Player"))
other.gameObject.SendMessage("update_near_door", false);
}
}