Changing Trigger Type Through Sequence Commands

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
pegassy
Posts: 135
Joined: Sat Mar 17, 2018 8:07 pm

Changing Trigger Type Through Sequence Commands

Post by pegassy »

Hello,

I am trying to start a conversation at trigger enter, and would like to turn into a "Use" type of trigger after the conversation is over. In the past I was doing this by disabling the conversation component and enabling another one, or by entirely adding another invisible game object that would have a different type.

However, I am wondering if there is an easier way of just switching the trigger type within Lua or Sequencer commands. I have not come across such a command yet.

Thank you for any pointers.
User avatar
Tony Li
Posts: 20990
Joined: Thu Jul 18, 2013 1:27 pm

Re: Changing Trigger Type Through Sequence Commands

Post by Tony Li »

Hi,

What about using the OnExecute() event like this:
switchTriggers.png
switchTriggers.png (33.34 KiB) Viewed 511 times
pegassy
Posts: 135
Joined: Sat Mar 17, 2018 8:07 pm

Re: Changing Trigger Type Through Sequence Commands

Post by pegassy »

So OnExecute() is used to call an event for any given game object? If I am using the .enabled function, does it pretty much do the same thing as SetComponent Enabled/Disabled action?

Is there a way to to access the trigger type and change that from trigger enter to use?
User avatar
Tony Li
Posts: 20990
Joined: Thu Jul 18, 2013 1:27 pm

Re: Changing Trigger Type Through Sequence Commands

Post by Tony Li »

pegassy wrote: Fri Dec 28, 2018 7:12 pmSo OnExecute() is used to call an event for any given game object? If I am using the .enabled function, does it pretty much do the same thing as SetComponent Enabled/Disabled action?
Yes. Set Component Enabled/Disabled would have been a better suggestion, which I presume is what you mentioned you were using in your first post.
pegassy wrote: Fri Dec 28, 2018 7:12 pmIs there a way to to access the trigger type and change that from trigger enter to use?
Not without a little scripting. I went with OnExecute() because I wanted to check if the inspector picked up the trigger type. It's just an enum variable, so I'm surprised the inspector didn't expose it to OnExecute(). Anyway, since I already had the OnExecute() section open, that's why I used it in the screenshot above instead of Set Component Enabled/Disabled.

You could add a small script like this to the same GameObject, and set OnExecute() to call SetTriggerType.SetToOnUse or SetTriggerType.SetToOnTriggerEnter:

SetTriggerType.cs

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

[RequireComponent(typeof(DialogueSystemTrigger))]
public class SetTriggerType : MonoBehaviour
{
    public void SetToOnUse()
    {
        SetTo(DialogueSystemTriggerEvent.OnUse);
    }

    public void SetToOnTriggerEnter()
    {
        SetTo(DialogueSystemTriggerEvent.OnUse);
    }

    public void SetTo(DialogueSystemTriggerEvent trigger)
    {
        GetComponent<DialogueSystemTrigger>().trigger = trigger;
    }
}
pegassy
Posts: 135
Joined: Sat Mar 17, 2018 8:07 pm

Re: Changing Trigger Type Through Sequence Commands

Post by pegassy »

Thank you.
User avatar
Tony Li
Posts: 20990
Joined: Thu Jul 18, 2013 1:27 pm

Re: Changing Trigger Type Through Sequence Commands

Post by Tony Li »

You're welcome! :-)
Post Reply