private void Update() { AICharacterInputs inputs = new AICharacterInputs(); // Simulate an input on all controlled characters inputs.MoveVector = Mathf.Sin(Time.time * MovementPeriod) * Vector3.forward; inputs.LookVector = Vector3.Slerp(-Vector3.forward, Vector3.forward, inputs.MoveVector.z).normalized; for (int i = 0; i < Characters.Length; i++) { Characters[i].SetInputs(ref inputs); } }
/// <summary> /// This is called every frame by the AI script in order to tell the character what its inputs are /// </summary> public void SetInputs(ref AICharacterInputs inputs) { _moveInputVector = inputs.MoveVector; _lookInputVector = inputs.LookVector; }