Weell bassicly i want to make a jumpscare but i m new and i cant still write down scripts if its possible someone to give one for me becouse all the scripts that are fount in the internet for the trigger are old and give me error i cannot fix i tryed everything.I want the jumpscare to play audio and my image to appear and be destroyed after that
Even if someone writes the script for you, you will still have to set up the colliiders, audio sources, and what-not in the scene. Instead of asking for handouts, you’ll get more help if you made an attempt first and then asked for help on a specific problem.
So break it down: You’re gonna need a script that has a reference to an ui-image and a audiosource. You’ll need to add a RigidBody to your player. Also need another GameObject that has a collider with the IsTrigger property set to true.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class JumpScare : MonoBehaviour {
public Image image;
public AudioSource audioSource;
void OnTriggerEnter(Collider other)
{
StartCoroutine(JumpScare_CR());
}
IEnumerator JumpScare_CR()
{
image.enabled = true;
audioSource.Play();
yield return new WaitForSeconds(0.5f);
image.enabled = false;
}
}
Should watch the Unity tutorials to familiarize yourself with Unity.