Page 1 of 1
Changing Trigger Type Through Sequence Commands
Posted: Fri Dec 28, 2018 2:06 pm
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.
Re: Changing Trigger Type Through Sequence Commands
Posted: Fri Dec 28, 2018 2:42 pm
by Tony Li
Hi,
What about using the OnExecute() event like this:
![switchTriggers.png](./download/file.php?id=428&sid=854e55dc115797b10f91ee24dbcd0946)
- switchTriggers.png (33.34 KiB) Viewed 524 times
Re: Changing Trigger Type Through Sequence Commands
Posted: Fri Dec 28, 2018 7:12 pm
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?
Re: Changing Trigger Type Through Sequence Commands
Posted: Fri Dec 28, 2018 8:09 pm
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;
}
}
Re: Changing Trigger Type Through Sequence Commands
Posted: Tue Jun 04, 2019 10:51 pm
by pegassy
Thank you.
Re: Changing Trigger Type Through Sequence Commands
Posted: Tue Jun 04, 2019 11:51 pm
by Tony Li
You're welcome!
![Smile :-)](./images/smilies/icon_e_smile.gif)