Hello
I have been trying to find how to detect a key being released. What I am attempting right now is that whenever the left shift key is pressed the players speed will increase and when let go it would revert back to the normal walking speed.
function Update() {
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded) {
moveDirection = Vector3(0, 0,
Input.GetAxis("Horizontal"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
print("Speed: " +speed); //Speed check
if(Input.GetKey ("left shift"))
{
speed = 5.0;
}
I have been looking at EventType.KeyUp but haven't been able to get it working properly. Is that the right approach? Can someone direct me in the right direction.
Thanks for the time and help!
No Problem man.
– anon36718473It's not good practice to assign things unnecessarily. Better to change the speed on press and release.
– Jessy