Some questions about angles and stuff...

Topics: Developer Forum, User Forum
Jan 21, 2013 at 7:31 PM
Edited Jan 21, 2013 at 7:31 PM

Hey,

 

So, we're trying to create a prototype for a game we'd like to develop - and, basically, we are at a point where we try to create a ragdoll made of different bodies and simply make it stand dynamically (that it still reacts to collisions etc, and the joints are kind of springy), and well, this pretty much works out okay, but we have a few questions.

 

First, how are the angles for the joints calculated? We pretty much got them by trial and error now, but that seriously isn't the point and I'm pretty sure this won't work out in later development stages. We create our joints by using revolute and angle joints combined, angle joints are pretty great for making that "springy" feel.

 

Second - my ragdoll stands perfectly, but no matter how much friction I put on ground and feet, it still seems to slide just a tiny bit without any influence from collisions for example. Any hints? This occured before when there was a huge tension on some joints, but right now, this isn't the case and I have seriously no idea on how to get rid of that.

 

Third, for my angle joints I have to use tiny, highly precise numbers like 0.965f while in the samples the values are around 3f. When I use values in that range, my joint is just completely stiff and pretty much doesn't react to outer influences at all anymore. Could this be due to my bodies not having enough mass?

Jan 22, 2013 at 3:50 AM

The angles are calculated relative to the body they are connected to.  For example, if you have an upper arm body connected to a forearm body via an Angle joint (call it the Elbow Joint), then if you set the angle to 0 the forearm will be at the same angle as the upper arm (a straight arm).  Changing the upper arm angle (via the shoulder joint) will rotate the upper arm and the forearm will go along with it (maintaining a straight arm pose).

The joint stiffness you're describing sounds like it's related to mass as you suspected.  You can tweak the Bias on the joint to affect the springyness, but I'm pretty sure the stiffness is going to be related to the mass.

Don't have any ideas for the friction issue.

-Mike.

Jan 22, 2013 at 12:59 PM
Edited Jan 22, 2013 at 1:04 PM

Hey Mike,

Awesome! Thank you. Really helps a lot.

But how are the degrees calculated? Is it deg*(pi/180) or something like that? Because it's not like I would enter degrees as values, this varies from like -9.1f to 7.4f.

I'm definitely going to try out giving my bodies more mass this evening, I'll report back.

 

Anyone else has an idea on the friction issue?

Maybe this could also be linked to the mass?

Jan 22, 2013 at 1:54 PM

All of the angles in Farseer use radians, not degrees -- so yes it is deg*(pi/180).  So if you're using -9.1f to 7.4f you're setting your angles between -521 and 401 degrees.  Anything over 360 degrees is a complete circle, so your angles are basically doing a complete revolution before arriving at the desired position.  If you find it easier to work in degrees instead of radians (who doesn't), you can use the MathHelper class to convert to degrees to radians and vice versa (MathHelper.ToRadians and MathHelper.ToDegrees).

Cheers,

Mike.

Jan 22, 2013 at 2:11 PM

Great. Thanks again, Mike!

Now for the friction problem, any ideas?

Jan 22, 2013 at 2:22 PM

I do have one idea for you: you say that your ragdoll stands perfectly, but you were also unclear on how the angles were calculated (and just used trial and error).  I'm guessing your ragdoll leg angles might be under stress (i.e. your setting somewhat conflicting Target angles amongst the different joints in your ragdoll).  If that's the case the legs might be vibrating slightly trying to reach the target angle.  This could cause the slide behavior you're seeing.

Worth looking into,

Mike.

Jan 22, 2013 at 2:50 PM

Sounds really plausible. That was also one of my ideas, since, as stated above, this behaviour also occured when joints where under huge tension because of wrong angles. Well, I guess I'm going to have another look over all angles tonight. And this time not via trial and error :D

Thanks a lot for your help!

Jan 22, 2013 at 7:55 PM
Edited Jan 22, 2013 at 7:57 PM

Uhh, the sliding problem persists. I fixed all angles and gave them better values using degrees and a degToRad const, worked out really well, but my character still slides very slowly without any influences.

Jan 22, 2013 at 8:08 PM

Check to see if the actual position of your bodies is changing... make sure it's a problem with the physics simulation and not a problem with your drawing.  Might also consider messing around with gravity some (change world gravity or body.IgnoreGravity=true) and see if that makes any difference.

Jan 22, 2013 at 8:23 PM
Edited Jan 23, 2013 at 3:11 PM

Body Position constantly changes, I tried messing around with gravity, friction, and mass of some body parts. No improvement. :(

 

EDIT: Okay, so now this gets really confusing. I set the MaxImpulse to zero for every Anglejoint, and when I lay my body on the floor, it goes asleep after 1 or 2 seconds, just like it should. But when I lay it on its left side, it slides and the whole body stays awake.

My ragdoll is facing to the right, meaning that the RevoluteJoints for, for example, the knees, use the same limits and the feet are facing to the right.

EDIT2: Wow. When I set the density of all bodies that the ragdoll has to 0.1f, the sliding actually stops while the anglejoints aren't active. However, as soon as I reactivate them, sliding starts again.

EDIT3: OH, WOW. The sliding also stops when I set the floor friction to ZERO. This makes no sense at all. :(

EDIT4: Okay, so I also posted this on stackoverflow to reach a wider audience. Link: http://stackoverflow.com/questions/14484106/endless-sliding-in-farseer-physics-with-angle-joints

Jan 25, 2013 at 2:04 PM
Edited Jan 25, 2013 at 2:17 PM

Okay, update time.

 

It seems like I was able to trace this error back to an angle joint which connects torso and throat.

For testing purposes, I simply set the softness of every angle joint to zero, meaning that, in theory at least, they should behave like they were one body. In fact, every joint became extremely stiff, just like it should - _except_ for the _throatTorsoAngleJoint! This thing just kept spinning around, with a *slight* springyness from the angle joint. Other than that, this angle joint would not take any settings I make, the revolute joint neither (e.g.: the limits won't work at all, no matter how I set them).

I tried to detach the throat from the torso > the joints between head and throat work perfectly. After that, I detached the throat from the torso, leaving it only attached with the head > joints worked perfectly. But as soon as I enable both joints, things start to get weird. I will look over this in a couple of days and then report back.

 

IMO this could cause the sliding as I could imagine there are many things wrong with this joint, so it could be possible that it just behaves like a revolute joint - and revolute joints keep flinging around when I don't stop them manually. So, if my head practically endlessly flings around, this would be a good reason for sliding. Another fact that supports this theory is that the body went asleep when I put it on its left side - I didn't notice this was the only position the head had contact to the floor, stopping it.

 

EDIT: Wouldn't this actually mean that I would be able to stop the sliding with angular damping? Oh god, so many things to try out.