Accessing Custom Classes with Custom Sequencer Commands

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
pixelemm
Posts: 5
Joined: Fri Jul 19, 2024 2:48 am

Accessing Custom Classes with Custom Sequencer Commands

Post by pixelemm »

Hi,

Is it possible for me to access classes not within the Dialogue System using a custom Sequencer Command?

This is what I would like to do: Find the mid point between a speaker and listener and use that as a Camera angle when calling the Camera() sequencer command.

I'm not sure if there is a better/correct way to do this but this is how I'm thinking of approaching it:
  1. Create custom camera angle set with a game object named "TwoPerson"
  2. Add a new script to the TwoPerson gameobject named "MidPoint" that has fields to assign two GameObjects and updates the position of TwoPerson gameobject
  3. In a new custom Sequencer Command, get the TwoPerson gameobject and access the midpoint class to assign the speaker and listener
However, I'm stuck at step 3 as the MidPoint class is not being recognised. ie its an unknown symbol.

Hope you could help me with this issue!
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Accessing Custom Classes with Custom Sequencer Commands

Post by Tony Li »

Hi,

Put your sequencer command script in your own scripts folder. If it's in Plugins, it will only have access to other scripts that are also inside Plugins. (A similar logic applies if you're using assembly definition files, too. If you haven't explicitly imported or set up assembly definitions, then you can ignore this sentence.)

You might not need a Midpoint script, though. Something like this will move a GameObject named "Midpoint" to a point between the speaker and listener:

Code: Select all

using UnityEngine;
namespace PixelCrushers.DialogueSystem.SequencerCommands
{
    public class SequencerCommandSetupMidpoint : SequencerCommand
    {
        private void Awake()
        {
            if (speaker == null || listener == null)
            {
                Debug.LogWarning("SetupMidpoint: Speaker and listener GameObjects must be assigned to conversation.");
            }
            else
            {
                var midpoint = GameObject.Find("Midpoint");
                midpoint.transform.position = (speaker.transform.position + listener.transform.position) / 2;
            }
            Stop();
        }
    }
}
Then use a Sequence like:

Code: Select all

SetupMidpoint()->Message(Ready);
Camera(Midpoint)@Message(Ready)
pixelemm
Posts: 5
Joined: Fri Jul 19, 2024 2:48 am

Re: Accessing Custom Classes with Custom Sequencer Commands

Post by pixelemm »

Ah!
Ok I got it! Thanks :)
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Accessing Custom Classes with Custom Sequencer Commands

Post by Tony Li »

Happy to help!
Post Reply