Jump to content

Recommended Posts

Posted

Made a script for a triggerbox that activates a message, but ran into a snag. The triggerbox works, but it spams the message until you get out of it. What script do I need to use to make it activate only once?

Posted

You can use a bool variable to prevent a portion of the event from running again.

You can use states to completely avoid the event at subsequent times.

 

However, it would be best if we could see the script code in question along with the precise behavior you want.

Posted (edited)

 

  Reveal hidden contents

Just wanting it so that when you walk through it a message pops up and activates just once, and that's it.
Edited by wilwhitt56
Posted

Use OnTriggerEnter as opposed to OnTrigger. OnTrigger will keep spamming like crazy while the object that triggered it remains inside.. OnTriggerEnter will do it only when the trigger is entered. But alone it will continue to trigger with each entry into the trigger.

 

If you do not need the trigger for anything else, you can have it disable itself.

 

See if the following works for you (please test re-entering the trigger area multiple times). Also be sure to test on a new game or a game that has not seen this trigger at the very least.

 

  Reveal hidden contents

 

Posted
  On 1/25/2022 at 12:26 AM, IsharaMeradin said:

Use OnTriggerEnter as opposed to OnTrigger. OnTrigger will keep spamming like crazy while the object that triggered it remains inside.. OnTriggerEnter will do it only when the trigger is entered. But alone it will continue to trigger with each entry into the trigger.

 

If you do not need the trigger for anything else, you can have it disable itself.

 

See if the following works for you (please test re-entering the trigger area multiple times). Also be sure to test on a new game or a game that has not seen this trigger at the very least.

 

  Reveal hidden contents

 

Yep it's working. I'm assuming self.disable() means it turns off the trigger when it's done, but what does Utility.Wait(0.25) do?

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...