|
well as you see I want this... when pressing Ctrl make height=2 > height=1 ( Crouch) I used get component but I don't know what to do cause it's not script.... thnx!
(comments are locked)
|
|
thnx man ... I used this : if (Input.GetKeyDown(KeyCode.LeftControl)) { if (controller.height == 2) controller.height = 1.8f; else controller.height = 2; } if (Input.GetKeyUp(KeyCode.LeftControl)) { if (controller.height == 1.8f) controller.height = 2; else controller.height = 1.8f; ... but there is another problem... when I crouch then get Up ... the collider will get over terrain so the camera goes under terrain and fall... IDK what should I do!
(comments are locked)
|
|
Not sure what you meant by using get component but you are able to access the character controller through getComponent try CharacterController controller = GetComponent(); if(Input.GetKeyDown(KeyCode.LeftControl)) { controller.height = 1; } it was supposed to be GetComponent();
Aug 15 '11 at 08:14 PM
illwunn
I didn't got it ... I put "if(Input.GetKeyDown(KeyCode.LeftControl)) { controller.height = 1; }" in Update... so I should tell what is "controller"... I add "CharacterController controller = GetComponent(); " up in public field... I used C#... but it give error that getcomponent is not right...
Aug 15 '11 at 08:23 PM
MobinS
(comments are locked)
|
|
ok i constructed a cube and attached a character controller to it with a height of 2 and then i attached a script called character that adjusts theheight when left ctrl is pressed the code was:
(comments are locked)
|
