コード例 #1
0
    void inputs()
    {
        xInput      = playerInput.getXTiltMove() * acceleration;
        zInput      = playerInput.getZTiltMove() * acceleration;
        sprintInput = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);

        if (!onGround)
        {
            jumpInput = false;
            jumping   = false;
        }
        else if (Input.GetKeyDown(KeyCode.Space) && onGround)
        {
            jumpInput = true;
        }

        if (Input.GetKeyDown(KeyCode.M) || Input.GetKeyDown(KeyCode.Tab))
        {
            if (mapChange < 0)
            {
                mapChange = 3f;
            }
            else
            {
                mapChange = -3f;
            }
        }
    }
コード例 #2
0
    private void inputs()
    {
        xInput      = playerInput.getXTiltMove() * acceleration;
        zInput      = playerInput.getZTiltMove() * acceleration;
        sprintInput = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);

        if (!onGround)
        {
            jumpInput = false;
        }
        else if (Input.GetKeyDown(KeyCode.Space) && onGround)
        {
            jumpInput = true;
        }
    }
コード例 #3
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftShift))
        {
            maxSpeed *= 1.7f;
        }
        else if (Input.GetKeyUp(KeyCode.LeftShift))
        {
            maxSpeed = maxSpeedOriginal;
        }

        if (!canMove)
        {
            return;
        }
        if (playerInput.getZTiltMove() > 0)
        {
            //walk.mute = false;
            zMove += moveSpeed * Time.deltaTime;
            if (zMove > maxSpeed)
            {
                zMove = maxSpeed;
            }
        }
        else if (zMove > 0 && Mathf.Abs(zMove) >= .05f)
        {
            zMove = Mathf.Lerp(zMove, zMove - (moveSpeed * Time.deltaTime), .5f);
            //walk.mute = true;
        }
        if (playerInput.getXTiltMove() > 0)
        {
            //walk.mute = false;
            xMove += moveSpeed * Time.deltaTime;
            if (xMove > maxSpeed)
            {
                xMove = maxSpeed;
            }
        }
        else if (xMove > 0 && Mathf.Abs(xMove) >= .05f)
        {
            xMove = Mathf.Lerp(xMove, xMove - (moveSpeed * Time.deltaTime), .5f);
            //walk.mute = true;
        }
        if (playerInput.getZTiltMove() < 0)
        {
            //walk.mute = false;
            zMove -= moveSpeed * Time.deltaTime;
            if (zMove < -maxSpeed)
            {
                zMove = -maxSpeed;
            }
        }
        else if (zMove < 0 && Mathf.Abs(zMove) >= .05f)
        {
            zMove = Mathf.Lerp(zMove, zMove + (moveSpeed * Time.deltaTime), .5f);
            //walk.mute = true;
        }
        if (playerInput.getXTiltMove() < 0)
        {
            //walk.mute = false;
            xMove -= moveSpeed * Time.deltaTime;
            if (xMove < -maxSpeed)
            {
                xMove = -maxSpeed;
            }
        }
        else if (xMove < 0 && Mathf.Abs(xMove) >= .05f)
        {
            xMove = Mathf.Lerp(xMove, xMove + (moveSpeed * Time.deltaTime), .5f);
            //walk.mute = true;
        }
        if (Mathf.Abs(xMove) < .05f)
        {
            xMove = Mathf.Lerp(xMove, 0f, .9f);
        }
        if (Mathf.Abs(zMove) < .05f)
        {
            zMove = Mathf.Lerp(zMove, 0f, .9f);
        }

        if (Input.GetButtonDown("Jump"))                //change to manual jumping outside of physics system
        {
            if (onGround)
            {
                playerBody.AddForce(new Vector3(0, jumpForce, 0));
            }
        }
    }