#I'm trying to implement a run Mechanic but it no no work ;'(

1 messages · Page 1 of 1 (latest)

jaunty flume
#

To put it simply, you can see the code in the picture is in a void Update but for some reason when I press shift it doesn't detect even though it should.

#
void Update()
    {
        var targetVector = new Vector3(_input.InputVector.x, 0, _input.InputVector.y);

        //Move in the direction we are aiming
        var movementVector = MoveTowardTarget(targetVector);

        if(Input.GetKeyDown("left shift"))
            speed = runSpeed * Time.deltaTime;
        else
            speed = moveSpeed * Time.deltaTime;
        //Rotate in the direction we are traveling
        RotateTowardMovementVector(movementVector);
        if(!rotateTowardsMouse)
            RotateTowardMovementVector(movementVector);
        else
            RotateTowardsMouseVector();
    }
mortal burrow
#

GetKeyDown will only be true for one single frame when you start pressing the button in question.
What you want, is GetKey.