# Directly Rotate a Hinge?

 0 Hey guys, I've got most of this game worked out, and it's actually functioning great, but I'm trying to add another control scheme and I can't seem to get it working... In the game, you're arms are attached to the body via hinge joint, and you press Left/Right to rotate them around using this type of action: ``````if(Input.GetKey("d")){ hingeJoint.motor.force = force; hingeJoint.motor.targetVelocity = 350; hingeJoint.motor.freeSpin = false; } ``````Now, I also set this up for use with my PS3 controller, as such: `````` if(Input.GetAxis("LHorz")){ hingeJoint.motor.force = force; hingeJoint.motor.targetVelocity = velo*rotspeed; hingeJoint.motor.freeSpin = false; ``````}What I want to be able to do, is instead of just adding to the motor's velocity, I want to be able to rotate the arm to point exactly where the analog stick is pointing. The code that I can use that works fine for a regular object is this: ``````var axisHorizontal = Input.GetAxis("Horizontal"); var axisVertical = Input.GetAxis("Vertical"); transform.localRotation = Quaternion.Euler((Mathf.Atan2(axisHorizontal, axisVertical) * Mathf.Rad2Deg), 0.0 , 0.0); ``````The problem is, is when you apply that code to the arms, which again are attached to the body by a hinge joint, the whole character just goes absolutely haywire...Here's a pic so you can get the idea of what motion I'm trying to get at:Thanks so much for any help! more ▼ asked Feb 07 '12 at 04:35 AM kewlhead 16 ● 6 ● 8 ● 8 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

Be the first one to answer this question

By Email:

Topics:

x2249
x223
x154
x41
x38

asked: Feb 07 '12 at 04:35 AM

Seen: 545 times

Last Updated: Feb 07 '12 at 04:35 AM