コード例 #1
0
        public bool IsDown()
        {
            float Axis = JoystickManager.GetAxis(JoystickNumber, AxisNumber);

            //Ensure that it is the same sign as the threshold, and beyond it.
            return((Math.Abs(Axis) >= Math.Abs(Threshold)) &&
                   (Math.Sign(Axis) == Math.Sign(Threshold)));
        }
コード例 #2
0
    private void Movement()
    {
        var h = -_joyManager.GetAxis(JoystickAxis.HORIZONTAL);
        var v = -_joyManager.GetAxis(JoystickAxis.VERTICAL);

        IsHolding = _joyManager.CheckButton(JoystickButton.B, Input.GetButton) && CanHold;

        if (!IsHolding)
        {
            currentSpeed = Mathf.SmoothDamp(currentSpeed, WalkSpeed, ref speedSmothvelocity, SPEED_SMOTH_TIME);
            MovementManger.NextPosition(transform, h, currentSpeed, TowerObject, Tower.CharacterLayer, ref lookDir, PlayerLookOffset);

            bool isAboveMid = false;
            if (IsAnchord)
            {
                isAboveMid = Anchor.position.y < (transform.position.y + Rope.offsetY);
            }
            else
            {
                isAboveMid = Rope.transform.position.y < (transform.position.y + Rope.offsetY);
            }

            if (!characterController.isGrounded && IsAnchord && !isAboveMid || !characterController.isGrounded && Rope.IsOtherHolding(PlayerNumber) && !isAboveMid)
            {
                velocityY = Mathf.Clamp(velocityY - Gravity * Time.fixedDeltaTime, MinV, MaxV);
                velocityY = Mathf.Clamp(velocityY + v * UpForce * Time.fixedDeltaTime, MinV, MaxV);
            }
            else
            {
                velocityY -= Gravity * Time.fixedDeltaTime;
            }

            characterController.Move(new Vector3(0, velocityY, 0) * Time.fixedDeltaTime);
        }

        if (characterController.isGrounded || IsHolding)
        {
            velocityY = 0;
        }

        UpdateAnimator(Mathf.Abs(h), characterController.isGrounded);
    }
コード例 #3
0
    void Update()
    {
        var rigidbody = GetComponent <Rigidbody>();
        var velocity  = rigidbody.velocity;

        //  Input.Axis
        var leftStick = JoystickManager.GetAxis();

        velocity.x = leftStick.x * moveSpeed * Time.deltaTime;

        //  Input.GetButton
        if (JoystickManager.GetButtonDown(0))
        {
            velocity.y = jumpVelocity;
        }

        rigidbody.velocity = velocity;
    }