H_SafeExperienceDrivingSystem/U3D_DrivingSystem/Assets/Script/Manaegr/CarTempManager.cs

62 lines
1.2 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.PlayerLoop;
public class CarTempManager : MonoBehaviour
{
private bool isTrgg = false;
private void OnTriggerStay(Collider other)
{
if (other.name == "动物")
{
if(isTrgg)
return;
isTrgg = true;
errorUI.SetActive(true);
che.GetComponent<Rigidbody>().isKinematic = true;
che.transform.position = new Vector3(che.transform.position.x-0.1f, che.transform.position.y, che.transform.position.z-0.1f);
Debug.Log(other.name);
MBOXManager.Instance.Bonk();
}
}
void Update()
{
if (Input.GetKeyDown(KeyCode.JoystickButton4))
{
errorUI.SetActive(false);
che.GetComponent<Rigidbody>().isKinematic = false;
}
}
private void OnTriggerExit(Collider other)
{
isTrgg = false;
}
private void OnTriggerEnter(Collider other)
{
}
public GameObject errorUI;
public GameObject che;
// private void OnCollisionEnter(Collision other)
// {
//
//
// Debug.Log(other.transform.name);
// }
}