void FixedUpdate()
 {
     if (inputBuffer.Count < character.InputBufferSize)
     {
         return;
     }
     character.CmdMove(inputBuffer.ToArray());
     inputBuffer.Clear();
 }
Exemple #2
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.F1))
        {
            simulated = !simulated;
        }
        Vector2 input = simulated ? SimulatedVector() : new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));

        if (inputBuffer.Count == 0 && input == Vector2.zero)
        {
            return;
        }
        predictor.AddInput(input);
        inputBuffer.Add(input);
        if (inputBuffer.Count < character.inputBufferSize)
        {
            return;
        }
        character.CmdMove(ConvertInputArray());
        inputBuffer.Clear();
    }