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);
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter