void FixedUpdate()
    {
        frameMovement.sprint = _movement.sprintTime;
        Vector3 tempForce = _movement.ApplyForces(frameMovement.forceNextFrame);

        MovementEvent?.Invoke(frameMovement);
        frameMovement                = new FrameMovement();
        frameMovement.position       = transform.position;
        frameMovement.forceNextFrame = tempForce;
    }
Exemplo n.º 2
0
 void NewMovement(FrameMovement frameMovement)
 {
     frameMovements.Add(frameMovement);
 }
    public void UpdateFromRecordedMovement(FrameMovement frameMovement)
    {
        _head.rotation = frameMovement.look;
        if (grabFrameBuffer > 0 || frameMovement.grab)
        {
            if (_grabber.Grab())
            {
                grabFrameBuffer = 0;
            }
            else
            {
                --grabFrameBuffer;
            }
        }
        if (frameMovement.release)
        {
            if (_grabber.Release())
            {
                grabFrameBuffer = 0;
            }
        }

        SetAnimatorValues(frameMovement.hMov, frameMovement.vMov);

        /*
         * if (frameMovement.jump) _movement.Jump();
         * _movement.sprintTime = frameMovement.sprint;
         * _movement.ApplyForces(frameMovement.forceNextFrame);
         *
         * if (Vector3.Distance(transform.position, frameMovement.position) < 0.1f)
         * {
         *  transform.position = frameMovement.position;
         * }
         * else
         * {
         *  Debug.Log(name + " desynced!");
         * }
         */

        if (synced && frameMovement.jump && !_feet.isGrounded && _movement.jumping)
        {
            //synced = false;
            Debug.Log(name + " desynced!");
        }

        if (synced)
        {
            _movement.Move(frameMovement.position);
        }
        else
        {
            if (frameMovement.jump)
            {
                _movement.Jump();
            }
            _movement.sprintTime = frameMovement.sprint;
            _movement.ApplyForces(frameMovement.forceNextFrame);
        }

        MovementEvent?.Invoke(frameMovement);
    }