- Home /
Make on object hinged to the player follow the cursor
Hi, I'm trying to make a specific type of control where the player has an "arm" attached to their model and can move it around with the mouse. However, I want only the far end to follow the mouse, with the hinged end staying firmly put. As it stands, I've tried to achieve this using a character joint between the player and the arm, and by putting another object at the end of the arm attached with another hinge and giving it
Vector3 temp = Input.mousePosition;
temp.z = 1f;
this.transform.position = Camera.main.ScreenToWorldPoint(temp);
However, this this causes the other object to separate from the arm, and causes the arms physics to freak out and send the player flying over the map. I've looked all over for something like this but can't seem to find it implemented anywhere. I'd really appreciate any help on how to do this, or just making following the mouse or using character joints better in general. I've included a poor doodle of my concept.
Answer by Arshia001 · Jul 23, 2016 at 04:41 PM
You can't just set the position of the object to the position you get from the mouse. It's bound by physics, and if you move physics objects to places where they're not supposed to be, they'll try to spring back rather violently. Instead, you could somehow calculate the rotation the arm should have and spin it around to that rotation. Also, do you really need physics for this? If the objects aren't physical, you should do the calculations yourself.
Your answer
![](https://koobas.hobune.stream/wayback/20220612085346im_/https://answers.unity.com/themes/thub/images/avi.jpg)