Page 1 of 1

Custom Sequence Commands

Posted: Tue May 26, 2020 12:28 pm
by rykaan
Hi Tony,

I've starting working on getting the basis for cut scenes in my game and I'm playing around with Custom Sequence Commands. Enjoying the versatility of them but I've run into a problem I'm having trouble working through.

I have two Custom Sequence Commands set up. One for giving a character a destination using the Pathfinding package I am using (AStarMoveTo). The other is to turn on and off player control input (PlayerControl). Here is my sequence:

AStarMoveTo(Cutscene Point, Speaker)->Message(PointReached);
PlayerControl(false)@Message(PointReached);
AStarMoveTo(Cutscene Point (1), Speaker)@Message(PointReached)->Message(NextPoint);
PlayerControl(true)@Message(NextPoint);

This is just a test sequence to see if I can set up the Commands correctly, in the vast number of cases input control will simply turn off at the start and on at the end.
The NPC does correctly move between the two points but the issue I am having is that the bottom line is triggering the 'false' response to the command instead of true (The code line with Debug.Log("Cutscene Disable Controls");). I'll show my code below:

Code: Select all

public class SequencerCommandPlayerControl : SequencerCommand
    {
        private PlayerInputControlScript playerInputControlScript;

        private bool controlsEnabled;

        public void Awake()
        {
            playerInputControlScript = GameManager.instance.GetComponent<PlayerInputControlScript>();
            controlsEnabled = GetSubject(0);
            
        }

        public void Start()
        {
            if (controlsEnabled == true)
            {
                Debug.Log("Cutscene Enable Controls");
                playerInputControlScript.InputEnable();
            } else
            {
                Debug.Log("Cutscene Disable Controls");
                playerInputControlScript.InputDisable();
            }
            Stop();
        }
And Here is the AStarMoveTo Command Code that triggers it. There's a slight delay on the response in the code so the Stop() command doesn't trigger the moment the path is set.

Code: Select all

public class SequencerCommandAStarMoveTo : SequencerCommand
    {
        private Transform target;
        private Transform subject;
        private AIDestinationScript aiDestinationScript;
        private float pathStartDelayTimer;
        private float pathStartDelayTimerMax = 0.5f;
        private bool pathStartDelayActive = false;

        public void Awake()
        {
            target = GetSubject(0);
            subject = GetSubject(1);

            if ((target == null) && DialogueDebug.logWarnings) Debug.LogWarning
                    (string.Format("{0}: Sequencer: MoveTo() target '{1}' wasn't found.", new System.Object[]
                    { DialogueDebug.Prefix, GetParameter(0) }));
            if ((subject == null) && DialogueDebug.logWarnings) Debug.LogWarning
                    (string.Format("{0}: Sequencer: MoveTo() subject '{1}' wasn't found.", new System.Object[]
                    { DialogueDebug.Prefix, GetParameter(1) }));

            // Set up the move:
            if ((subject != null) && (target != null) && (subject != target))
            {
                aiDestinationScript = subject.GetComponent<AIDestinationScript>();
            }
        }

        public void Start()
        {
            aiDestinationScript.AIDestination(target.position);
            pathStartDelayActive = true;
        }

        public void Update()
        {
            if (pathStartDelayActive == true)
            {
                pathStartDelayTimer = pathStartDelayTimer + Time.deltaTime;
            }
            if (aiDestinationScript.pathComplete() == true &&
                pathStartDelayTimer > pathStartDelayTimerMax)
            {
                Debug.Log("Destination Reached");
                pathStartDelayActive = false;
                pathStartDelayTimer = 0f;
                Stop();
            }
        }
Sorry for the long message. This is my first time playing with these commands so I am having a little trouble figuring out if my sequence syntax is incorrect, or I've made a code mistake.

Cheers,
Rob

Re: Custom Sequence Commands

Posted: Tue May 26, 2020 1:25 pm
by Tony Li
Hi Rob,

Instead of this:

Code: Select all

controlsEnabled = GetSubject(0);
use this:

Code: Select all

 controlsEnabled = GetParameterAsBool(0);

Re: Custom Sequence Commands

Posted: Wed May 27, 2020 5:14 am
by rykaan
Ah of course, sorry I really should have realised. I must be relying on the error highlighting too much and assumed there wasn't an issue there. Cheers for the speedy reply as always.