-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriggerObject.cs
More file actions
67 lines (59 loc) · 1.75 KB
/
TriggerObject.cs
File metadata and controls
67 lines (59 loc) · 1.75 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TriggerObject : MonoBehaviour {
//Triggername Serialize Field makes provate variables public
[SerializeField]
string objTag;
private RaycastFromPlayer buttonParams;// CHANGE THIS!!!!
// Use this for initialization
void Start () {
buttonParams = GameObject.FindObjectOfType<RaycastFromPlayer>();
}
// Update is called once per frame
void Update () {
}
//Checks to see if obj entered trigger.
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == objTag) {
// Debug.Log("Entered");
}
}
//Checks to see if obj is still inside the trigger.
private void OnTriggerStay(Collider other)
{
if (other.gameObject.tag == objTag)
{
Debug.Log(other.gameObject.tag);
//Checks to see if item is placed correctly
if(other.gameObject.tag == "RedBox")
{
buttonParams.RedBlock = true;
Debug.Log("redbox!");
}
if (other.gameObject.tag == "BlueBox")
{
buttonParams.BlueBlock = true;
Debug.Log("bluebox!");
}
}
}
//Checks to see if obj left the trigger.
private void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == objTag)
{
//Checks to see if item fell off the plate
Debug.Log("Left");
if (other.gameObject.tag == "RedBox")
{
buttonParams.RedBlock = false;
}
if (other.gameObject.tag == "BlueBox")
{
buttonParams.BlueBlock = false;
}
}
}
}