Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Can you help me please?

Discussion in 'Scripting' started by unity_1FFE8133FD63935BA749, Oct 19, 2023.

  1. unity_1FFE8133FD63935BA749

    unity_1FFE8133FD63935BA749

    Joined:
    Oct 14, 2023
    Posts:
    2
    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);
    }
    }
     
  2. Nad_B

    Nad_B

    Joined:
    Aug 1, 2021
    Posts:
    395