- Home /
Question by
CrilleStyles · May 03, 2014 at 10:00 AM ·
script.gun scriptglobal scriptstatic script
Wrong with script
What's wrong?
if(Input.GetKeyDown(KeyCode.LeftShift) {
transform.rotation = Quaternion.Euler(20,0,0);
else
transform.rotation = Quaternion.Euler(90,0,0);
Comment
if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.LeftShift)) {
transform.rotation = Quaternion.Euler(20,0,0);
}
else{
transform.rotation = Quaternion.Euler(90,0,0);
}
Does this work?
Depends on what you want to achieve with this code.
No It doesn't I'm making arms go up when running and then go down again after running
Best Answer
Answer by Subhajit-Nath · May 03, 2014 at 10:10 AM
Input.GetKeyDown returns true for only ONE frame. On the next frame it returns false.
So, if you are willing to keep the rotation value for more than one frame (that is, as long as you keep pressing the LeftShift) you should use Input.GetKey instead.
Your answer
Follow this Question
Related Questions
Script Error 1 Answer
Realistic reloading system 1 Answer
Only Get Parent Collision, not child 2 Answers
How do do i reference standard asset scripts in another script? 1 Answer
Problem freezing the game with 1 game over script over many objects 0 Answers