Hey!
I want a specific dialogue to play ONLY if I take some damage. It's meant to only play once and never again. Is there a way to do this ?
Play dialouge once player takes damage
-
- Posts: 82
- Joined: Wed Mar 31, 2021 6:48 pm
Re: Play dialouge once player takes damage
Hi,
Here's how to play a conversation only once: How To: Run a Conversation Only Once
To play it when the player first takes damage, you'll need some kind of script or event that runs when the player takes damage. You can either set up a Dialogue System Trigger and manually call its OnUse() method, or call DialogueManager.StartConversation() directly. Example:
Here's how to play a conversation only once: How To: Run a Conversation Only Once
To play it when the player first takes damage, you'll need some kind of script or event that runs when the player takes damage. You can either set up a Dialogue System Trigger and manually call its OnUse() method, or call DialogueManager.StartConversation() directly. Example:
Code: Select all
using PixelCrushers.DialogueSystem;
...
public void TakeDamage(int damage)
{
health -= damage;
if (DialogueLua.GetVariable("hasPlayedDamageDialogue").asBool == false)
{
DialogueLua.SetVariable("hasPlayedDamageDialogue", true);
DialogueManager.StartConversation("You Took Damage");
}
}
-
- Posts: 82
- Joined: Wed Mar 31, 2021 6:48 pm
Re: Play dialouge once player takes damage
Awesome! I figured I needed a script, and your example of one will be great for me to use. Thanks!
Re: Play dialouge once player takes damage
Glad to help!
-
- Posts: 82
- Joined: Wed Mar 31, 2021 6:48 pm
Re: Play dialouge once player takes damage
Hey Sorry again, but I was wondering why the "Onconversation" end doesn't run when I run a dialogue through script?
On the start of a conversation, I have a function that makes the player movement false, but for some reason, this function doesn't run at all when I activate dialogue via code.
On the start of a conversation, I have a function that makes the player movement false, but for some reason, this function doesn't run at all when I activate dialogue via code.
Re: Play dialouge once player takes damage
Hi,
OnConversationStart and OnConversationEnd (and the related Dialogue System Events component) only run on the Dialogue Manager GameObject and the GameObjects that are being used as the conversation's current actor and conversant.
If you start a conversation through script, pass the GameObjects:
or add Dialogue Actor components to them so they can register themselves as being the GameObjects associated with the actors in the database.
More info:
OnConversationStart and OnConversationEnd (and the related Dialogue System Events component) only run on the Dialogue Manager GameObject and the GameObjects that are being used as the conversation's current actor and conversant.
If you start a conversation through script, pass the GameObjects:
Code: Select all
DialogueManager.StartConversation("You Took Damage", playerTransform);
More info:
- Character GameObject Assignments
- Dialogue Actor
- Script Messages (which GameObjects are notified)
-
- Posts: 82
- Joined: Wed Mar 31, 2021 6:48 pm
Re: Play dialouge once player takes damage
Thank you so much Tony! Assigning the player's transform did the trick!