コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (_omni.enabled && !_omni.omniFound)
        {
            _omni.enabled = false;
        }

        var pos = HeadPosition.position - transform.position;

        pos.y = 0.5f;

        _controller.center = pos;

        yVel -= 9.8 * Time.deltaTime * 0.1;

        if (_controller.isGrounded)
        {
            yVel = 0;
        }

        var rotationSpeed = movement.GetAxis(handType).x;

        if (Mathf.Abs(rotationSpeed) < 0.1)
        {
            rotationSpeed = 0;
        }

        var speed = movement.GetAxis(handType).y;

        if (Mathf.Abs(speed) < 0.1)
        {
            speed = 0;
        }
        var direction = HeadPosition.forward * speed * 4 * Time.deltaTime;

        direction.y = (float)yVel;
        _controller.Move(direction);

        // Omni movement
        if (_omni.omniFound)
        {
            _omni.GetOmniInputForCharacterMovement();

            if (_omni.GetForwardMovement() != Vector3.zero)
            {
                _controller.Move(_omni.GetForwardMovement());
            }
            if (_omni.GetStrafeMovement() != Vector3.zero)
            {
                _controller.Move(_omni.GetStrafeMovement());
            }
        }
        //transform.Rotate(new Vector3(0, rotationSpeed * speed * 100 * Time.deltaTime, 0));
    }
コード例 #2
0
    // Gets Omni Movement Vectors from the OmniMovementComponent and uses them to Move the Player
    void UseOmniInputToMovePlayer()
    {
        if (MovementComponent.omniFound)
        {
            MovementComponent.GetOmniInputForCharacterMovement();
        }
        else if (MovementComponent.developerMode)
        {
            MovementComponent.DeveloperModeUpdate();
        }


        if (MovementComponent.GetForwardMovement() != Vector3.zero)
        {
            m_CharacterController.Move(MovementComponent.GetForwardMovement());
        }
        if (MovementComponent.GetStrafeMovement() != Vector3.zero)
        {
            m_CharacterController.Move(MovementComponent.GetStrafeMovement());
        }
    }