I want to know how to use the trigger function.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
minomod
Posts: 89
Joined: Mon Jun 19, 2017 9:17 am

I want to know how to use the trigger function.

Post by minomod »

[img]2.png[/img] [img]1.png[/img]

1. I want to know how to use the trigger function.

2. I want to know how ready conversations will run after a certain amount of time during the game.
Attachments
2.png
2.png (59.38 KiB) Viewed 1058 times
1.png
1.png (60.29 KiB) Viewed 1058 times
User avatar
Tony Li
Posts: 21033
Joined: Thu Jul 18, 2013 1:27 pm

Re: I want to know how to use the trigger function.

Post by Tony Li »

Hello,

The dropdown (in your first image) shows the different ways you can configure the Conversation Trigger component to start a conversation. For example, if you set it to OnTriggerEnter then it will start a conversation when Unity's physics system detects a trigger collision. See the NPC named Private Hart in the Feature Demo scene for an example.

The Conversation Trigger will only start the conversation if the Condition section is true or empty. For example, if you only want to start the conversation is a GameObject tagged "Player" enters the trigger, then set Condition > Accepted Tags to "Player".

If you only want to start the conversation if a certain amount of time has passed, this is one way:

1. In the Dialogue Editor window, define a variable. Set its Type to Boolean. Leave its Initial Value at False. Let's say the variable is named "TimePassed".

2. Set the Conversation Trigger's Condition > Lua Conditions to:

Code: Select all

Variable["TimePassed"] == true
3. In your own script, when a certain amount of time has passed, set the variable true:

Code: Select all

using PixelCrushers.DialogueSystem;
...
DialogueLua.SetVariable("TimePassed", true);
minomod
Posts: 89
Joined: Mon Jun 19, 2017 9:17 am

Re: I want to know how to use the trigger function.

Post by minomod »

I proceeded as described but it is not.
Attachments
3.png
3.png (37.61 KiB) Viewed 1053 times
User avatar
Tony Li
Posts: 21033
Joined: Thu Jul 18, 2013 1:27 pm

Re: I want to know how to use the trigger function.

Post by Tony Li »

Hi,

Your Conversation Trigger will attempt to run when its GameObject receives an "OnUse" message. Have you configured your scene so it will receive an "OnUse" message? For example, the Selector or ProximitySelector component can be configured to send "OnUse".

When the Conversation Trigger attempts to run, it will check the Condition. If the Variable["TimePassed"] is true, it will start the conversation. It will also display "True" in the Inspector. If the Variable["TimePassed"] is false, it will display "False" in the Inspector.

If you don't see True or False in the Inspector, this means the Conversation Trigger did not receive an "OnUse" message.
minomod
Posts: 89
Joined: Mon Jun 19, 2017 9:17 am

Re: I want to know how to use the trigger function.

Post by minomod »

When I took the log, I noticed that Timepassed changed from False to true. But I do not know what to set the trigger to.

I hope that the ambassadors that have been prepared will proceed.
Attachments
4.png
4.png (20.36 KiB) Viewed 1050 times
User avatar
Tony Li
Posts: 21033
Joined: Thu Jul 18, 2013 1:27 pm

Re: I want to know how to use the trigger function.

Post by Tony Li »

How do you want the conversation to start?
  • When the player uses a Selector to "use" the object? (Set Trigger to OnUse)
  • When the scene starts? (Set Trigger to OnStart)
  • When a GameObject enters the trigger collider area? (Set Trigger to OnTriggerEnter)
  • etc.
minomod
Posts: 89
Joined: Mon Jun 19, 2017 9:17 am

Re: I want to know how to use the trigger function.

Post by minomod »

This is the scene I'm going to make.
1. When you start the game, the characters move around a limited area for about 20 seconds.
2. After 20 seconds, the unconditionally prepared conversation proceeds.

The solution I thought was like this. After a certain amount of time, activate the tricker object in the area and let the player enter the tricker unconditionally. Another way to resolve this is to continue with the inquiry.
User avatar
Tony Li
Posts: 21033
Joined: Thu Jul 18, 2013 1:27 pm

Re: I want to know how to use the trigger function.

Post by Tony Li »

In this case, you don't need a Condition or a "TimePassed" variable. I recommend setting up a Conversation Trigger with OnUse. Then add a script like this to the same GameObject:

DelayedConversationStart.cs

Code: Select all

using UnityEngine;
using System.Collections;
using PixelCrushers.DialogueSystem;

public class DelayedConversationStart : MonoBehaviour {

    public float delay = 20f;
    
    IEnumerator Start() {
        yield return new WaitForSeconds(delay);
        GetComponent<ConversationTrigger>().OnUse();
    }
} 
minomod
Posts: 89
Joined: Mon Jun 19, 2017 9:17 am

Re: I want to know how to use the trigger function.

Post by minomod »

Thanks a lot ^ ^ Thanks for your help. We will contact you again if you have any further questions.
Post Reply