holopy3/Assets/Scripts/HandTrigger.cs

61 lines
1.3 KiB
C#
Raw Normal View History

2020-12-10 14:25:12 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HandTrigger : MonoBehaviour
{
public Material Brickwall;
public Material Hedge;
public Material Glass;
public Material OGlass;
private int count = 1;
private int brickwall = 1;
private int hedge = 2;
private int glass = 3;
private int oglass = 4;
// 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.gameObject.CompareTag("Wall"))
{
MeshRenderer mr = other.gameObject.GetComponent<MeshRenderer>();
print(mr.material);
if (count == brickwall)
{
mr.material = Hedge;
count = 2;
}
else if (count == hedge)
{
mr.material = Glass;
count = 3;
}
else if (count == glass)
{
mr.material = OGlass;
count = 4;
}
else if (count == oglass)
{
mr.material = Brickwall;
count = 1;
}
}
}
}