Game Development Reference
In-Depth Information
Assets\Scripts ) and update the ThePlayerIsTryingToLeave method with the
following code:
void ThePlayerIsTryingToLeave()
{
var dialog = GetComponent<ConversationComponent>();
if (dialog != null)
{
if (dialog.Conversations != null &&
dialog.Conversations.Length > 0)
{
var conversation = dialog.Conversations[0];
if (conversation != null)
{
ConversationManager.Instance.StartConversation
(conversation);
}
}
}
}
Here, we now look to see if a ConversationComponent script is on the game object
it is attached to. If it is, we see if there are any conversations defined for this NPC; if yes,
we call the ConversationManager script and ask it to start the first conversation.
Note
Granted that this is a simple example and should be extended in a full system to track con-
versations that are played or conditions that need to be met for a conversation to be
played.
At the moment, the conversation system will keep on going even after you have left the
vicinity of the character you are talking with.
Now, if you run the project and try to enter the cave, the grumpy old Greybeard will pipe
up and harass you. , as shown in the following screenshot:
Search WWH ::




Custom Search