I am new in unity scripting so i need some help fast. I want to destroy the jumpscare object afer jumpscare here is the script.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class jumpscareScript : MonoBehaviour
{
public string scenename;
public float jumpscareTimer;
public AudioSource jumpScareSound;
public GameObject jumpScareCam;
public GameObject player;
void Start()
{
jumpScareCam.SetActive(false);
}
void OnTriggerEnter(Collider other)
{
StartCoroutine(JumpScarePlayer());
}
IEnumerator JumpScarePlayer()
{
jumpScareSound.Play();
jumpScareCam.SetActive(true);
player.SetActive(false);
yield return new WaitForSeconds(jumpscareTimer);
SceneManager.LoadScene(scenename);
}
}