//Happens in Play mode //Uses the NavMeshAgent to control the units, delegating their movement and animations to the AI private void ProcessPlayModeFrame(Playable playable) { int inputCount = playable.GetInputCount(); for (int i = 0; i < inputCount; i++) { float inputWeight = playable.GetInputWeight(i); ScriptPlayable <AICommandBehaviour> inputPlayable = (ScriptPlayable <AICommandBehaviour>)playable.GetInput(i); AICommandBehaviour input = inputPlayable.GetBehaviour(); //Make the Unit script execute the command if (inputWeight > 0f) { if (!input.commandExecuted) { AICommand c = new AICommand(input.commandType, input.targetPosition, input.targetUnit); trackBinding.ExecuteCommand(c); input.commandExecuted = true; //this prevents the command to be executed every frame of this clip } } } }
public void IssueCommand(AICommand cmd) { selectedPlatoon.ExecuteCommand(cmd); }