KillZone | Showreel

PHOTO EMBED

Tue May 17 2022 16:11:51 GMT+0000 (Coordinated Universal Time)

Saved by @BiscuitTinx #c#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class DeathZone : MonoBehaviour
{
    private void OnTriggerEnter(Collider c)
    {
        if (c.tag == ("Player"))
        {
            Rigidbody RB = c.gameObject.GetComponent<Rigidbody>();
            RB.constraints = RigidbodyConstraints.None;
            RB.AddForce(1, 1, 1, ForceMode.Impulse);
            PlayerMovement playerMovement = c.gameObject.GetComponent<PlayerMovement>();
            playerMovement.enabled = false;

            StartCoroutine(SwapScene());
        }

        if (c.tag == ("Ai"))
        {
            Rigidbody RB = c.gameObject.GetComponent<Rigidbody>();
            RB.constraints = RigidbodyConstraints.None;
            RB.AddForce(1, 1, 1, ForceMode.Impulse);
            WanderAi wanderAi = c.gameObject.GetComponent<WanderAi>();
            wanderAi.enabled = false;

            Destroy(c.gameObject, 5f);
        }
    }

    IEnumerator SwapScene()
    {
        yield return new WaitForSeconds(5f);
        SceneManager.LoadScene(2);
    }
}

content_copyCOPY