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();
}
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();
}
}
Cheers,
Rob