Hey Tony,
I wish to build a custom distance-based wait method for the sequencer.
Something like etc. SetActive(obj, true)->WaitInRange(player, distance).
How would I achieve something like this?
Custom Sequencer Wait Message
Re: Custom Sequencer Wait Message
Hi,
Please see part 6 of the Cutscene Sequence Tutorials: Custom Sequencer Commands to get a general idea of how to write custom sequencer commands. Then duplicate SequencerCommandTemplate.cs, move it to your own folder, and rename it to something like SequencerCommandWaitInRange.cs.
The syntax of sequencer commands doesn't allow for "->WaitInRange()", but you can do something like:
or, if you'll only use this to activate GameObjects, you can write a command SequencerCommandActivateWhenInRange::
I'll outline the first version. Briefly, you'd fill in the code for Start(), Update(), and possibly OnDestroy(). Something like:
Please see part 6 of the Cutscene Sequence Tutorials: Custom Sequencer Commands to get a general idea of how to write custom sequencer commands. Then duplicate SequencerCommandTemplate.cs, move it to your own folder, and rename it to something like SequencerCommandWaitInRange.cs.
The syntax of sequencer commands doesn't allow for "->WaitInRange()", but you can do something like:
Code: Select all
WaitInRange(obj, player, distance)->Message(PlayerIsInRange);
SetActive(obj, true)@Message(PlayerIsInRange)
Code: Select all
ActivateWhenInRange(obj, player, distance)
Code: Select all
using UnityEngine;
namespace PixelCrushers.DialogueSystem.SequencerCommands
{
public class SequencerCommandWaitInRange : SequencerCommand
{
private Transform obj;
private Transform mover;
private float distance;
private void Start()
{
obj = GetSubject(0);
mover = GetSubject(1);
distance = GetParameterAsFloat(2);
}
private void Update()
{
if (Vector3.Distance(obj.position, mover.position) < distance)
{
Stop(); // We're in range.
}
}
}
}
Re: Custom Sequencer Wait Message
Ah I see. Thank you for your help!
Re: Custom Sequencer Wait Message
Glad to help!