I guess this is mainly geared towards amcerbu...but I was wondering if anyone has any experience with using rag doll physics?
I'm kind of testing my own method as of now...not very far into it, but basically every body part has two locations (top and bottom) that dictate it's position and direction. Also each part has a parent object that it inherits the position of and then builds off of for it's final position. That's about all I have right now.
Offline
Makes sense. And yeah, amcerbu an you are the two people I'd probably trust most for Something like this XD. I'd suggest a way for it to inherent force from its "child" maybe?
Offline
Oh, yeah. That stuff's really hard. I saw a ragdoll physics article out on the internet awhile ago where "inverse kinematics" was concerned. The way they explained it, kinematics is the study of determining the location of, say, the hand at the end of the arm, based on the angles of the joints. Inverse kinematics tries to determine angles for the joints to produce a desired location for the hand. I'm not exactly sure what that has to do with ragdolls, but you can check out the page for yourself.
Anyway, here's the link. Good luck! Maybe I'll play around with something, but I'm not very hopeful that I'll get anywhere.
Offline
amcerbu wrote:
Oh, yeah. That stuff's really hard. I saw a ragdoll physics article out on the internet awhile ago where "inverse kinematics" was concerned. The way they explained it, kinematics is the study of determining the location of, say, the hand at the end of the arm, based on the angles of the joints. Inverse kinematics tries to determine angles for the joints to produce a desired location for the hand. I'm not exactly sure what that has to do with ragdolls, but you can check out the page for yourself.
Anyway, here's the link. Good luck! Maybe I'll play around with something, but I'm not very hopeful that I'll get anywhere.
Thanks! Looks like a pretty good article.
Offline
Wes64 wrote:
You may find more help in Advanced Topics, even though this is the proper forum
Maybe...but I'd rather try and figure it out with someone then just have someone tell me how to do absolutely everything.
Ok, so update on the idea: Position 1 for every part is calculated by the inheritance and what not. Position 2 is then calculated with this:
Distance = sqrt( (1.x-2.x)^2 + (1.y-2.y)^2)
2.x = 1.x + ( (1.x-2.x)*length)/Distance
2.y = 1.y + ( (1.y-2.y)*length)/Distance
Where length is a predetermined number. This avoids using trig and rotation which I feel will leave room for vector velocity with x and y components instead of a velocity based off direction and a magnitude.
It could also be used during the inheritance process as well.
Last edited by AtomicBawm3 (2012-07-12 13:34:52)
Offline
amcerbu wrote:
^^ I love vectors. They make trig look so unnecessary.
Lol, yeah...still, trig does have to be used because I'm making the parts out of costumes...but it's minimal, only an arc-tangent really
Offline
Hey amcerbu: would you be able to look at my scripts? I thought I got it all right, but it doesn't work at all.
Offline
Are you talking about the stuff you posted above with distance constraints? So far, I can't see anything wrong with it.
A few other questions: what shape are you simulating? A stickman? Something more complicated? Also, how fast do you want this to run?
And here's an idea for implementation (at least, this is how I'd do it): Everything is based on a central "source point." For this project, the lines won't have mass, just the points, and we'll say all masses are equal. Each point has an "impulse" velocity; the way it wants to travel. It will try to travel that way. When it reaches a distance constraint, it projects its velocity onto its constraints; any points it is attached to. The remaining velocity (the vector "rejection") is given to the point at the other end of the constraint. You may have to do some recursive stuff to get all the points to affect all the other ones.
If you manage to implement what the guy did in that article I posted, adding velocity won't be terribly difficult.
Offline
Hmmm. What amcerbu said sounds about right. Just a suggestion, depending on how you want to do this, you could have it be one sprite an one script by stamping each body parts costume, or if it's simple, using the pen.
Offline
1s1sKing wrote:
Hmmm. What amcerbu said sounds about right. Just a suggestion, depending on how you want to do this, you could have it be one sprite an one script by stamping each body parts costume, or if it's simple, using the pen.
Yeah...I kind of started out that way, but I decided not to because it's easier sometimes to have calculations shown in separate broadcasts...and I'm running it very slow right now. Still not working. I'll upload it tomorrow to my test account and let you look. It is a human body as well with 10 parts (upper and lower legs and arms, torso, and head).
Offline
Hmmm. Broadcasts lag a lot... You might want to build it for turbo mode, or it could end up lagging to much for the regular players, but going to fast in turbo. If you could, putting them in a single script. Since your length is set, you could probably do all the calculations, then render the body parts based on it. I definitely want to see how this turns out
And again, I would reccomend keeping it a single script. It would lag much less. If your computer has trouble with it, save often and put the end of the script in a forever/repeat until block, then insert the second to last smallish segment, etc until your script is done. Alternatively, you could try the clean up scripts button so you just have to go to the bottom and drag the bits in. Can't Wai to see this finished.
Offline
Hey, AtomicBawm3: Check out this article.
It has some interesting stuff about cloth dynamics and something close to ragdoll physics. I hope you've had some Calculus in school (or, at least Pre-Calc) because there's stuff about Verlet Integration.
I'd suggest you read the entire thing; it's pretty cool and you might be able use some of the things they talk about, especially where distance constraints are concerned.
Gamasutra has some really good articles, so there's probably more out there.
Last edited by amcerbu (2012-07-13 00:19:58)
Offline
1s1sKing wrote:
Hmmm. Broadcasts lag a lot... You might want to build it for turbo mode, or it could end up lagging to much for the regular players, but going to fast in turbo. If you could, putting them in a single script. Since your length is set, you could probably do all the calculations, then render the body parts based on it. I definitely want to see how this turns out
And again, I would reccomend keeping it a single script. It would lag much less. If your computer has trouble with it, save often and put the end of the script in a forever/repeat until block, then insert the second to last smallish segment, etc until your script is done. Alternatively, you could try the clean up scripts button so you just have to go to the bottom and drag the bits in. Can't Wai to see this finished.
Again, I'm not going for speed yet, I'm going for accuracy. I'll go for speed once I know it can work at a very slow rate.
Offline
@1s1sKing- "Too fast in Turbo" can be fixed using what I like to call a "framerate" lock; every script is called in sequence with "broadcast _ and wait," and the script waits for the remaining time (I use 1/30 second, or 30 frames/second) before repeating. This especially prevents flickering in pen projects.
But, back to the topic, AB3: I'll check out your project in the morning. I hope you have time to look at the Gamasutra article (I'm never sure whether anyone sees posts when they get buried underneath other ones).
Offline
Well you guys seem to be having a pleasant conversation . I figured out my problem by making this...I'll get back to you if the body system starts working.
EDIT: Amcerbu: I might read it...but I hate the layout of the article and it hurts my eyes...thanks though.
Last edited by AtomicBawm3 (2012-07-13 11:14:07)
Offline
amcerbu wrote:
I'm checking out your "Pull Line" project right now.
Here's the version with gravity and velocity: Link.
Seems to work pretty well! I think what I'm going to have to do for the body once I'm ready is to have 5 separate pull lines, one for each limb and one for the head/torso. Then the limb pull lines depend on perpendicular lines that hook into the torso and the torso is dependent on the head which is dependent on the mouse.
Offline
amcerbu wrote:
I've gotta say, the rope with velocity looks really good. Perhaps it would be nice if you included an option to adjust friction (or is it hard-coded into your script?).
Currently it is, but I was going to make different values for different parts...maybe. But yeah, maybe I'll do that.
Offline
Ok, I'm writing this because I'd like somebody to look over the math for this one final time...clearly I've already got most of the physics figured out, but I needed to figure out how to create offsets for the arms and legs so that they were a tad more realistic. Here's the math I've come up with that avoids using trig to find a point rotated from any location:
Let's say that you've got a line for the middle of the body in the form y=mx+b based off of the two points at either end of the torso. Info needed:
Length of torso= 40 (for now)
m=(x1-x2)/(y1-y2) (of torso)
Offset on the y-axis (oy)= -4 (again, for now)
Offset on the x-axis (ox)= -10
and of course, x1, x2, y1, and y2
Basically, I'm going to calculate two vectors that are perpendicular to each other where the vector for y uses m and the vector for x uses -1/m. Vector 1 can be calculated like so:
V1.X = -4(x1-x2)/40
V1.X = (x2-x1)/10
V1.Y = -4(y1-y2)/40
V1.Y = (y2-y1)/10
This vector is simple enough to calculate, but the perpendicular vector took some work:
First, you have to calculate a vector in the correct direction, which is simple enough since we know that a perpendicular line is simply -1/m. Giving the vector the imaginary points of (x,y) and (x+1,y-1/m) we can clearly see that:
dx = -1
dy = 1/m
so our vector's current distance is sqrt(1/(m^2)+1). To make the vector the right length, we simply do what I've been doing for all of the point calculations:
(x,y) of vector = (-dx*l/dist, -dy*l/dist)
so our vector becomes:
V2.X = -10/dist
V2.Y = -10/(m*dist)
To get the final position:
Final.X = Start.X + V1.X + V2.X
Final.Y = Start.Y + V1.Y + V2.Y
where Start is point 1.
Anyway...that's probably more confusing than it should be...but it should work.
Offline