- Home /
Arm rotation question
Hey.. i did this script for move an arm up and down, but is not how I wanted to..
in this script, if i press Z or X the arm moves up and down continuously .. why? i would like that if i press Z the arm go up end if i press X go down.. hope someone can help me !
thank you in advance
Answer by dagon · May 28, 2014 at 11:21 AM
you can move many time:
if (Input.GetKey (KeyCode.Z)) {
arm_rot = (Mathf.Sin (arm_sin) * 30.0f) - 30.0f; arm_sin = (arm_sin + Time.deltaTime * 5.0f) % 360.0f; int i = 0; if(i<arm_rot){arm[0].transform.localEulerAngles = new Vector3 (i, 0.0f, 0.0f ); i++;} }
Uff i can't understand why when i press Z or X the arm moves continuously up and down :'(
You are currently using Input.Get$$anonymous$$ey
which returns true as long as that key is held down. If you only want it to execute once per key press, you will want to Input.Get$$anonymous$$eyDown
ins$$anonymous$$d.
I did so, but the rotation is jerky.. I think is not that the problem , because the movement is right, but i don't understand why if i I hold down Z or X the movement is up and down together.. while if i press Z should be go up, and with X the arm should go down.. hope you understand.. (sorry for my english)
Your answer
Follow this Question
Related Questions
C# Mathf.PingPong Rotate Back and Forth 2 Answers
Clamping negative and positive values. 1 Answer
How does this AND Mathf.Sin actually work?! 2 Answers
Mathf.Lerp Question 2 Answers