- Home /
Move up and down one arm
Hi guys, How can i do for move an arm up and down? (look at the picture for understand) I would like that if i press a key it moves up increasing speed, and if press another key it moves down increasing speed. If any keys is pressed, the arm remains in last position
Detail: if i keep the key pressed, the force increase more fast (up or down), and if i press key quickly, the force is more slowly.
I Hope I explained, and sorry for my bad english!
I attach the image:
Answer by madstk1 · Feb 24, 2014 at 08:32 PM
Well first off, we can see the options we have..
I thought of one, and it worked.
Set the rotation of the object.
---Remember---
Attach a Rigidbody and set it to useGravity = false
Make a box-collider, where you want it to stop moving.
And just attach this script to the object you want to move.
--Code--
var rotationSpeed : int = 10;
function Update ()
{
if(Input.GetKey(KeyCode.UpArrow))
{
transform.Rotate (0, 0, 1 * Time.deltaTime * rotationSpeed, Space.World);
}
if(Input.GetKey(KeyCode.DownArrow))
{
transform.Rotate (0, 0, -1 * Time.deltaTime * rotationSpeed, Space.World);
}
}
Thanks for your reply. Ok I tried this, the arm don't moves up and down on your own pivot point, and i had to remove the box-collider, otherwise the arm disappears.
maybe i have to change the pivot point? How can I do for put the pivot point as in picture that i've posted?
Your answer
Follow this Question
Related Questions
"Hover" object up and down 2 Answers
Realistic walking. 1 Answer
GameObject automatically moves up when upgrade is purchased. 2 Answers
Moving Object up and down without player input (such as a spike that kills you) 2 Answers
Slowly speed something up to a top speed after a specified amount of time? 0 Answers