# Articulated physics using RevoluteJoints / Contstraints with target angle

Hi,

Note: i already tried to post this before but it seemingly got lost in Akismet and has been in limbo for a while already so i am trying again. Sorry for any inconvenience this may cause unintentionally!

I want to get into Rust and thought re-implementing older experiments of mine in Rust would be a good way to start with that. So i want to re-implement some prototypes i did in other languages that used mouse movements mapped to target angles of revolute joints to create physics based gameplay with direct mouse/controller control.

Reading the docs i could not find a built in way to have a RevoluteJoint or Contstraint with a target angle / spring. I just wanted to make sure i did not miss anything and also ask if anyone has some hints on how to best implement this.

Thorsten

Hi!

You can set a target velocity for the `RevoluteJoint` but not a target angle/spring. I am not sure what you mean by “taret angle/spring”, could you please elaborate? Does this mean that you want to be able to tell the revolute joint to reach a given position (given by an angle) with a given maximal motor force (given by what you call the “spring”)?

Hi and thanks for the reply!

So the type of setup i am trying to create is similar to the one in good old Ski Stunt Simulator. You control the pose of the Skier directly with your mouse and everything else is plain physics. Another example would be the Diver games by Jeff Webber (Diver 2 Trailer - YouTube)

So basically i am mapping the control to directly control the target angle between the limbs. I used Spring here as that happens to be the implementation in one of the other languages / engines i tried this. In another one, Farseer Physics, it was possible to combine a RevoluteJoint with a so called AngleJoint that allows the RevoluteJoint to maintain a fixed angle between the two bodies. That angle is dynamic. By controlling the angles with the controller i get what i am after.

Here is a demo from Farseer that illustrates the desired effect quite well i think:

Cheers,
Thorsten

Thank you for the details!

So, yeah, what you are looking for is to be able to ask the physics engine to make is so that a joint reaches a specific position (angle). `nphysics` has no way of doing this for you. What you would have to do is to set the joint’s velocity until the joint reaches the desired angle. Though with this kind of control, you will have to be careful to avoid overshooting, or jittering.

By the way, in case you don’t know, `nphysics` isn’t being improved anymore, so I’m afraid the feature we are talking about here will never be added to `nphysics`. The new library replacing `nphysics` is Rapier but it doesn’t have joint motors yet. Adding joint motors in Rapier is planed for later this year.

Thanks a lot for the reply again. And thanks for mentioning nphysics is not actively improved i was not aware of that! Will look into Rapier! Thanks a lot!