Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

triggers / events

so i'm making a game with a death-zone and i'm having some trouble with doing an event system

what i want is when the fps player goes into the death zone, a sound will play and he will be sent to the beginning... but i'm having problems with the fact that i don't know how to make the trigger play a sound or do an event, i think its something to do with a script but i'm only starting to learn c# off of Brackeys video

this is a photoshop thing of which is what i want it to look like ( i added the On enter () to it in photoshop )

shouldn't be that hard because what i want to do is add the AudioManager to it and play a death sound

thanks

Answers

  • anyone?

  • MouledouxMouledoux Member
    edited June 28

    I've made a script like this before, but cant find my original. Anyway, here's what it might of looked like:

    public class OnTriggerEvent : MonoBehaviour
    {
         public UnityEngine.Events.UnityEvent onTriggerEnterEvent;
         void OnTriggerEnter(collider other)
         {
              onTriggerEnterEvent.Invoke();
         }
    }
    


    Just put this script next to your collider, and it will look a lot like the picture you made.

    You can even add your own onTriggerExitEvent, or onTriggerStayEvent, and add them to this script the same way.

  • thanks, really helpfull

  • Thank you so much this is a great help!

  • ++

  • what?

  • what what?

  • what do you need

  • i was just asking what ++ means but don't worry

Sign In or Register to comment.