Getting speaker and listener game objects. Is this good?
Posted: Thu Feb 08, 2024 1:44 pm
Hi there,
I needed to get the game object associated with the current speaker and/or listener in an active convo, and after some research, including one of my old posts (deja vu feeling here), I've figured out a solution to use from a PlayMaker CallMethod action...
Here's the code I've used:
It's working and that's great, but I'd still like a sanity check from you, Tony.
Thanks.
I needed to get the game object associated with the current speaker and/or listener in an active convo, and after some research, including one of my old posts (deja vu feeling here), I've figured out a solution to use from a PlayMaker CallMethod action...
Here's the code I've used:
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace PixelCrushers.DialogueSystem.SequencerCommands
{
public class GetCurrentSpeakerListener : SequencerCommand
{
public GameObject CurrentSpeaker()
{
if (!DialogueManager.isConversationActive) return null;
Transform subject = GetSubject("speaker");
return subject.gameObject;
}
public GameObject CurrentListener()
{
if (!DialogueManager.isConversationActive) return null;
Transform subject = GetSubject("listener");
return subject.gameObject;
}
}
}
Thanks.