Game Crashes when object gets near player

Viewed 40

THIS POST IS NOW IRRELEVANT PLEASE CHECK MY NEWER ONE

I am making a horror game with next bots on VR (Quest/Quest2)

the player has 1 "Mixed" light on it and the bots use pathfinding AI with navmeshes and stuff but it seems that when the next bot gets within I'll say like 10 feet of the player and the player can see it and all the game just decides it wants to freeze and stop working!

It seems to happen before the player "Dies" but I'm not fully sure.

public class Kill : MonoBehaviour
{
    // Start is called before the first frame update

    public GameObject tes;
    public GameObject LocoToOff;
    public Vector3 SPOT;
    public GameObject SprintLoco;
    public GameObject Dead;
    public AudioSource audioSource;
    private bool Using;
    public GameObject Safe;
    public LocomotionControllery Loco;
    private bool ChillOutItsGoing;

    IEnumerator TurnOff()
    {
        ChillOutItsGoing = true;
        LocoToOff.SetActive(false);
        SprintLoco.SetActive(false);

        Dead.SetActive(true);


        Loco.Disabled = true;

        audioSource.Play();

        yield return new WaitForSeconds(3);


        //foreach (var pls in WallsNStuff)
        //{
        //    pls.SetActive(false);
        //}


        tes.transform.position = SPOT;


        //yield return new WaitForSeconds(0.05f);


        Loco.Disabled = false;

        Dead.SetActive(false);

        //foreach (var pls in WallsNStuff)
        //{
        //    pls.SetActive(true);
        //}

        Safe.SetActive(true);

        ChillOutItsGoing = false;
    }

    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "BOT")
        {
            if (ChillOutItsGoing == false)
            {
                Debug.Log(other.gameObject.name);
                Using = LocoToOff.active;
                StartCoroutine(TurnOff());
            }
        }
    }

}
1 Answers

I believe it ended up just being because the thing was set to "Cutout" instead of opaque and Cutout I think is in alpha only 2 things I changed that fixed it for sure was setting it to opaque and adding a lil bit of smoothness (just did that idk if it was part of the fix or not)

Related