Files
PuzzleColorBall/Assets/Scripts/portal.cs

28 lines
624 B
C#
Raw Normal View History

2023-05-13 15:30:19 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class portal : MonoBehaviour
{
private GroundController gc;
2023-05-29 15:36:27 +02:00
private int random;
2023-05-13 15:30:19 +02:00
void Awake()
{
gc = FindObjectOfType<GroundController>();
2023-05-29 14:36:51 +02:00
2023-05-29 15:36:27 +02:00
random = UnityEngine.Random.Range(0, gc.materials.Length);
2023-05-29 14:36:51 +02:00
2023-05-29 15:36:27 +02:00
gameObject.GetComponent<MeshRenderer>().material = gc.materials[random];
2023-05-13 15:30:19 +02:00
}
private void OnTriggerEnter(Collider other)
{
2023-05-16 14:27:55 +02:00
if(other.gameObject.tag.Equals("Player")){
2023-05-29 15:36:27 +02:00
gc.ChangeMaterial(gc.materials[random]);
gc.ModuleColorChange();
2023-05-16 14:27:55 +02:00
}
2023-05-13 15:30:19 +02:00
}
}