Exemplo n.º 1
0
        private void FixedUpdate()
        {
            // read user input: movement
            float h = Input.GetAxis("Horizontal");
            float v = Input.GetAxis("Vertical");

            // calculate move direction and magnitude to pass to character
            Vector3 camForward = new Vector3(_camTransform.forward.x, 0, _camTransform.forward.z).normalized;
            Vector3 move       = v * camForward + h * _camTransform.right;

            if (move.magnitude > 1)
            {
                move.Normalize();
            }

            ProcessDamage();

            // pass all parameters to the character control script
            _character.Move(move, _crouch, _jumpPressed);
            _jumpPressed = false;

            // if ragdolled, add a little move
            if (_ragdoll != null && _ragdoll.IsRagdolled)
            {
                _ragdoll.AddExtraMove(move * 100 * Time.deltaTime);
            }
        }