H_SafeExperienceDrivingSystem/U3D_DrivingSystem/Assets/Script/Old/Early_Warning.cs

40 lines
963 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Early_Warning : MonoBehaviour
{
/// <summary>
/// 必然发生标志位
/// </summary>
bool Certain_Occur =true;
/// <summary>
/// 随机发生
/// </summary>
bool isTrigger = true ;
// Start is called before the first frame update
private void OnTriggerEnter(Collider other)
{
if (other.name == "ColliderBody")
{
Random_Occur();
print("ISTRIGGER" + isTrigger);
if (!isTrigger)
return;
//下面执行交叉预警功能
transform.GetChild(0).gameObject.SetActive(true);
}
}
private void Random_Occur()
{
if (Certain_Occur)
{
Certain_Occur = false;
return;
}
isTrigger = Random.Range(0, 3) > 1 ? true : false;//随机0.12大与1触发
}
}