Page 1 of 1

OnTriggerEnter

Posted: Tue Sep 28, 2021 2:41 pm
by SealDev
Would it be possible to use a Dialogue System Trigger component with ontriggerenter so that it runs every frame?
I'm aware this would be bad for conversations but also very useful for running Sequence commands!
You can also use SendMessage to run a function every frame but only while inside a trigger. How cool is that!



Alternatively, if I can run this code on update. Is it bad for performance?

Code: Select all

//trigger = GetComponent<DialogueSystemTrigger>();
    void Update()
    {
        trigger.OnUse();
    }

Re: OnTriggerEnter

Posted: Tue Sep 28, 2021 2:59 pm
by Tony Li
Hi,

It's possible to do that, but I wouldn't recommend it for performance reasons. If you can write it natively in C#, it will be more performant. For example, you can use OnTriggerStay:

Code: Select all

void OnTriggerStay(Collider other)
{
    if (other.CompareTag("Player"))
    {
        SomeFunction();
    }
}