Page 1 of 1
How to block player's path?
Posted: Fri Jan 05, 2024 8:35 pm
by Mastodon
Hello, I was curious if anyone could help me. I wanted to know how to block the player from going to any scene if they have to do something first. Like talking to an NPC.
For example, if the player tries to go to that area a conversation will show up saying "I should talk to X first". I have all of the scene portals set up for my game so far so now it's just about setting restrictions.
Re: How to block player's path?
Posted: Fri Jan 05, 2024 10:29 pm
by Tony Li
Hi,
You could use a subclass of ScenePortal like this:
ConditionalScenePortal.cs
Code: Select all
using PixelCrushers;
using PixelCrushers.DialogueSystem;
public class ConditionalScenePortal : ScenePortal
{
public Condition condition;
[ConversationPopup(true)] public string conditionsUnmetConversation;
public override void UsePortal()
{
if (condition.IsTrue(null))
{
base.UsePortal();
}
else
{
DialogueManager.StartConversation(conditionsUnmetConversation);
}
}
}
It adds a
Condition section and a
Conditions Umnet Conversation.
Then set the Condition section. For example, use the Lua Conditions subsection to check if a variable is true:
Code: Select all
Variable["Talked_To_NPC_X"] == true
In the conversation with NPC X, set the variable true.
If the variable is true when the player enters the Scene Portal, it will go to the next scene. Otherwise it will play the Conditions Unmet Conversation.
Re: How to block player's path?
Posted: Sat Jan 06, 2024 11:45 am
by Mastodon
Awesome it works perfectly! Thank you so much for the help!
Re: How to block player's path?
Posted: Sat Jan 06, 2024 2:23 pm
by Tony Li
Glad to help!