-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLockActivator.cs
More file actions
41 lines (36 loc) · 1.04 KB
/
Copy pathLockActivator.cs
File metadata and controls
41 lines (36 loc) · 1.04 KB
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LockActivator : MonoBehaviour
{
[SerializeField] GameObject door;
[SerializeField] BoxCollider boxCollider;
Player player;
private void Start()
{
player = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();
}
private void OnTriggerStay(Collider other)
{
if (player.hasKey)
{
UIManager.instance.TypeInteract("Press E to open the gate.");
if (Input.GetKeyDown(KeyCode.E))
{
OpenDoor();
UIManager.instance.HideInteract();
}
}
}
private void OnTriggerExit(Collider other)
{
UIManager.instance.HideInteract();
}
private void OpenDoor()
{
door.transform.localEulerAngles = new Vector3(90, 0, -90);
boxCollider.center = new Vector3(boxCollider.center.x, boxCollider.center.y, 0.9510078f);
boxCollider.size = new Vector3(boxCollider.center.x, boxCollider.center.y, 1.218079f);
Object.Destroy(gameObject);
}
}