Trigger Zones - Unity Quick Tip

Поділитися
Вставка
  • Опубліковано 24 січ 2025

КОМЕНТАРІ • 33

  • @ViralSpiralMedia
    @ViralSpiralMedia 7 місяців тому +1

    I have spent hours watch YT vids, trying to get interactions working, but finally you have a solution that works! Many thanks.

  • @krissosful
    @krissosful Рік тому +4

    Awesome tutorial and nice interior result, keep going👏👏

  • @hermionegreen333
    @hermionegreen333 10 місяців тому +3

    quick and super informative thank you!

  • @jeromecormiermusic
    @jeromecormiermusic 6 місяців тому

    Thank you very very much, this is quite a fundamental tip for many critical uses in Unity and should be taught as such in the software basics 🙏

  • @juliestrator
    @juliestrator 2 роки тому +10

    Now I know how to trigger anyone, thanks :)

  • @0pix.ziplock
    @0pix.ziplock 7 місяців тому +1

    how to do this with animation?Help please(

  • @Takhooo
    @Takhooo Рік тому +2

    YOU GOTTA MAKE MORE YOU THE GOAT

  • @AetherXIV
    @AetherXIV Рік тому

    I don't know how you are so good at blender and coding. nice

  • @jcashbeatzrh
    @jcashbeatzrh 3 місяці тому

    Exactly what I was looking for! Subbed

  • @707_FAISAL
    @707_FAISAL 5 місяців тому

    i have a Question how can i make trigger updated every single frame cuz i want make that if you on trigger & press button something happen

  • @Nico.desb7
    @Nico.desb7 10 місяців тому +4

    i get an error saying that the type "Trigger" already contains a definition for "OnTriggerExit". No clue how to solve it, probably because i have other scripts that override this one but i'm too new into coding to solve it for myself.

    • @NadeemM-f2v
      @NadeemM-f2v 5 місяців тому

      You use onTriggerExit two times rather than using onTriggerEnter

  • @romeo774
    @romeo774 7 місяців тому

    for some reason when i use the destroy after enter feature my sound no longer plays at all. any fix?

  • @TheNSproject
    @TheNSproject Рік тому

    Thank you so much for your video! Do you have a tuto to show a trigger by clicking the object?

  • @Woowoowoostudio
    @Woowoowoostudio 23 дні тому

    Anyone know how to apply this to text?

  • @HxsrzStudio
    @HxsrzStudio Рік тому

    bro your videos, are super helpful

  • @elrovlez6440
    @elrovlez6440 7 місяців тому

    Great video! Thanks for sharing.

  • @Low_Fidelity_3D
    @Low_Fidelity_3D Рік тому

    been seeing you all over Godot twitter as of recent while you learn your way around the game engine. Do you think you may start making tutorials/ related videos covering it?

  • @damnthishandleistaken
    @damnthishandleistaken Рік тому

    Can you make a tutorial on weapon animations next?

  • @hamishdelaforce1048
    @hamishdelaforce1048 7 місяців тому +1

    this helped alot thanks :)

  • @dazimbsdoc69
    @dazimbsdoc69 11 місяців тому +1

    this is too fast i cant keep even with pausing like at exactly 0:18 you'll see what im talking about.

  • @torontogamestudio2991
    @torontogamestudio2991 Рік тому

    Game Changer. Pun Intended

  • @oliver_rocks80
    @oliver_rocks80 10 місяців тому

    Jump scare warning 1:44 😱

  • @1playfair
    @1playfair Рік тому

    Guessing this won’t work in 2019.4.40f1 where my game lives 😅

  • @torontogamestudio2991
    @torontogamestudio2991 Рік тому +1

    Thank you so much, such a useful peice of code, But for the love of God can you please at least pause on the code for once second for me to copy lol

  • @DerRattenfänger
    @DerRattenfänger 7 місяців тому

  • @lucutes2936
    @lucutes2936 8 місяців тому

    creepy

  • @setik1337
    @setik1337 10 місяців тому +28

    Full script:
    using System;
    using UnityEngine;
    using UnityEngine.Events;
    public class Trigger : MonoBehaviour
    {
    [SerializeField] bool destroyOnTriggerEnter;
    [SerializeField] string tagFilter;
    [SerializeField] UnityEvent onTriggerEnter;
    [SerializeField] UnityEvent onTriggerExit;
    void OnTriggerEnter(Collider other)
    {
    if (!String.IsNullOrEmpty(tagFilter) && !other.gameObject.CompareTag(tagFilter)) return;
    onTriggerEnter.Invoke();
    if (destroyOnTriggerEnter)
    {
    Destroy(gameObject);
    }
    }
    void OnTriggerExit(Collider other)
    {
    if (!String.IsNullOrEmpty(tagFilter) && !other.gameObject.CompareTag(tagFilter)) return;
    onTriggerExit.Invoke();
    }
    }