targetcollider.cs
660 Bytes
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class targetcollider : MonoBehaviour
{
public static targetcollider instance;
void Awake() {
if(instance == null) {
instance = this;
}
}
void OnTriggerEnter(Collider other) {
moveTarget();
}
public void moveTarget() {
Vector3 temp;
temp.x = Random.Range(-2f, 2f);
temp.y = Random.Range(1f, 3f);
temp.z = Random.Range(-2f, 2f);
transform.position = new Vector3(temp.x,temp.y,temp.z);
RaycastController.instance.playSound(0);
}
}