Sequencer Command in code

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
nathanj
Posts: 303
Joined: Sat May 28, 2016 12:30 am

Sequencer Command in code

Post by nathanj »

Hi Tony,

I've been looking around on the site but I can't find an answer to this.

I'm trying to have the player LookAt() the NPC when a conversation is started. I could run the command from the sequencer in the dialogue node but since this is a generic camera controller script I would like to have it assigned automatically so I don't need to add it in at every conversation.
I'm trying:

public void OnConversationStart (Transform actor)
{
DialogueManager.PlaySequence(""LookAt(listener))
}

but I get a message saying: "taget is null". Could you tell me how I could feel the transform position of the NPC into that command? Also, this script is on a game object that is a child of the NPC I am trying to get.

Thanks,
Nathan
User avatar
Tony Li
Posts: 22057
Joined: Thu Jul 18, 2013 1:27 pm

Re: Sequencer Command in code

Post by Tony Li »

Hi Nathan,

The Dialogue System calls OnConversationStart on both primary participants (actor and conversant), passing it the transform of the other participant. You could bypass the sequencer command and do this:

Code: Select all

void OnConversationStart(Transform other)
{
    transform.LookAt(other);
}
Or you could use the sequencer command like this:

Code: Select all

void OnConversationStart(Transform other)
{
    DialogueManager.PlaySequence("LookAt(listener)", this.transform, other);
}
The second parameter (this.transform) is the "speaker", and the third parameter (other) is the "listener".
User avatar
nathanj
Posts: 303
Joined: Sat May 28, 2016 12:30 am

Re: Sequencer Command in code

Post by nathanj »

The second worked for me!

Thanks again for the speedy response
Post Reply