RunUpdate() public method

Run update like classic unity's Update We use an other method here because the calling must be controlled by CharacterNetwork We can't use standard Update method because Unity update order is non-deterministic
public RunUpdate ( float delta ) : void
delta float
return void
Example #1
0
    void FixedUpdate()
    {
        //Client: Please read: http://forum.unity3d.com/threads/tips-for-server-authoritative-player-movement.199538/

        //Client: Only client run simulation in realtime for the player to see
        if (isLocalPlayer)
        {
            //Client: start a new state
            localInputState = localInputState + 1;
            //Client: Updates camera
            cameraMouseAim.RunUpdate(Time.fixedDeltaTime);
            cameraAimPoint.RunUpdate(Time.fixedDeltaTime);
            //Client: gathers user input state
            characterInput.Parse(localInputState);
            //Client: add new input to the list
            inputStates.Enqueue(characterInput.currentInput);
            //Client: execute simulation on local data
            characterMovement.RunUpdate(Time.fixedDeltaTime);
            characterRotation.RunUpdate(Time.fixedDeltaTime);
            //Client: Trim commands to 25 and send commands to server
            if (inputStates.Count > WARNING_CLIENT_WAITING_STATES)
            {
                Debug.LogWarning("[NetworkInput]: States starting pulling up, are network condition bad?");
            }
            if (inputStates.Count > MAX_CLIENT_WAITING_STATES)
            {
                Debug.LogError("Too many waiting states, starting to drop frames");
            }
            while (inputStates.Count > MAX_CLIENT_WAITING_STATES)
            {
                inputStates.Dequeue();
            }
            //Client: Send every sendInterval
            if (isServer && isLocalPlayer || nextSendTime < Time.time)
            {
                CmdSetServerInput(inputStates.ToArray(), transform.position);
                nextSendTime = Time.time + 0.33f;
            }
        }
    }