Hi . I am beginner in unity and scripting and i need some help.
What script can i add to remove this object after jumpscare( or just after interaction)
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);
}
}