Files
PuzzleColorBall/Assets/Scripts/portal.cs
2023-05-30 20:14:07 +02:00

28 lines
626 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class portal : MonoBehaviour
{
private GroundController gc;
private int random;
void Awake()
{
gc = FindObjectOfType<GroundController>();
random = UnityEngine.Random.Range(0, gc.materials.Length);
gameObject.GetComponent<MeshRenderer>().material = gc.materials[random];
}
private void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag.Equals("Player")){
gc.ChangeMaterial(gc.materials[random]);
//gc.ModuleColorChange();
}
}
}