- Home /
Holding Ctrl prevents character from moving
When I hold down the left control key then press press W,A,S or D nothing happens but if I press it after I press and hold W,A,S or D it works properly.
WASD move the character and left control is set to make the character crouch and move slower. All of this is setup in the InputManager.
I tried commenting out code that I wrote that is affected by the ctrl key and nothing changed.
Answer by robertbu · Jul 23, 2013 at 05:37 AM
It looks like the issue is inherent in the Input Manager. Work arounds use Input.GetKey() to hard code the logic rather than use the Input Manager.
http://answers.unity3d.com/questions/173836/combined-keys-action.html
I tried using Get$$anonymous$$ey and still having the same results. But I used Get$$anonymous$$ey with E and it worked fine. Seems the be a problem with the control key.
I'm not clear and exactly how you want the keys structured, but here is a bit of code as an example of capturing the control keys. Attach it to an empty game object and play with combinations of 'Ctrl' and 'W':
#pragma strict
var bCrouchAndSlow = false;
function Update() {
var leftCtrl = Input.Get$$anonymous$$ey($$anonymous$$eyCode.LeftControl );
var rightCtrl = Input.Get$$anonymous$$ey($$anonymous$$eyCode.RightControl);
bCrouchAndSlow = leftCtrl || rightCtrl;
if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.W)) {
if (bCrouchAndSlow)
Debug.Log("$$anonymous$$oving forward crouching and and slowly");
else
Debug.Log("$$anonymous$$oving forward upright and quickly");
}
}
Answer by superdudeman · Mar 04, 2015 at 08:38 PM
I'm having the exact same problem and am surprised there aren't more complaints about it! Anyway it only seems to be an issue in the Unity editor. When building and running it, it stops happening. I guess the Unity editor is listening for the left ctrl key.