OnTriggerEnter Issue

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Nazazel
Posts: 2
Joined: Wed May 25, 2016 5:46 pm

OnTriggerEnter Issue

Post by Nazazel »

Hi Tony,

This is Naz. My team and I are having issues with our scripts working with the ones from the Dialogue Manager specifically with a script that uses the OnTriggerEnter method. The issue is that one of our scripts also uses OnTriggerEnter as a means to transition from scene to scene within our game but when used with the Dialogue Manager--say on a character within our game--it overrides our script because it takes the Dialogue Manager's scripts as priority. Is there a work around this issue?
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: OnTriggerEnter Issue

Post by Tony Li »

Hi Naz,

It's possible to change the priority of scripts (Edit > Project Settings > Script Execution Order), but this may not be what you really want to do.

When a GameObject with a collider and rigidbody enters another GameObject's trigger collider, Unity calls the OnTriggerEnter method on all scripts on both GameObjects. All of the OnTriggerEnter methods will be called in the same frame.

Can you put these scripts on the GameObjects that aren't the player character? For example, if you have a GameObject with a trigger collider that transitions to another scene, put the script on that GameObject, not the player.

Similarly, if you have an NPC that starts a conversation when its trigger collider is entered, put the Conversation Trigger on the NPC, not on the player.

If the info above doesn't help, please post some more details about what you're trying to do and what's happening. Or feel free to send an example project to tony (at) pixelcrushers.com.
Nazazel
Posts: 2
Joined: Wed May 25, 2016 5:46 pm

Re: OnTriggerEnter Issue

Post by Nazazel »

Thank you so much for the suggestions. Ultimately, we decided to remove our script from the scene to avoid any overlap with the way the Dialogue Manager works. Instead, rather than having something initiate a transition into the next scene, we'll be making it timed. So, after a certain amount of time, the scene will just transition.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: OnTriggerEnter Issue

Post by Tony Li »

Sounds good! If any other issues come up, just let me know! :-)
Post Reply