Game Maker Community: Ragdoll + Physics Engine(s) - Submit Your Editable - Game Maker Community

Jump to content

Advanced Users Forum Rules

This is a Q&A forum for advanced GML users ONLY. Moderators will remove inappropriate topics. Make sure that you READ these rules prior to posting: Advanced Users Forum Rules
  • (21 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

Ragdoll + Physics Engine(s) - Submit Your Editable ** Old Experts Topic **

#21 User is offline   Hitman 

  • Shadowfied
  • Group: GMC Member
  • Posts: 91
  • Joined: 26-October 03

Post icon  Posted 19 February 2004 - 05:11 PM

Ok. first i propose a scientific outlook based on reason with this problem.

in other words, lets first ask (state) the problem.

Quote

-we need a realistic movement that creates an illusion of force against an object with (reliatively) some mass and densisty that it actually dosen't have.


then we need to hypothosize (brain storm) an outcome and try to visualize a ragdoll effect in real life (easily done with k-nex dudes :unsure: )

Quote

-in the world of 'the real' velocity plays a key role on inertia and rotation. IE. if a person is hit in the chest with a 50 pound wieght flying at a velocity of 30kph (excluding pain and body damage) his body will do the following. first the torso will arc away from the projectile, wthe arms will bed at the elbows and move up towards the chest(already 7 joints have been mentioned. elbows {2} shoulder{2}
torso {3})  . then the current position of the legs will manuvere in the same way of the arms but towards the the direction of the projectiles pervious velocity. that is the legs will ben at the knees {2}. then the head will arc towards the chest {1}. after that its time for momentium to kick in along with rotation and inertia. the entire body will rotate away from the projectile (clockwise if coming from the left and vise versa) with equal velocity but descreasing momentum, after that inertia will spread the limbs apart (like gravity versus friction does to sky divers) and out wards.


thus will be the outcome of a projectile hiting a human chest at 30kph . now that the 'rag doll' effect has been explained we just need to hypothosize a solution to the problem. how would we do it?

Quote

-joints are the main issue, thankfully if one is to think, three-dimensional engines are not needed for this. imaging an arm cut off at the elbow and the shoulder.
if this limb is rotated  (shoulder in the center) a radius is created (the length of the arm) . therefor two joints are seen, the elbow at

dx = x + (radius * cos(image_single*30 * 3.14 / 180));
dy = y - (radius * sin(image_single*30 * 3.14 / 180));
instance_create(dx,dy,elbowjoint)

and the shoulder at 0 (bounding x sign in sprite editor menu)

thats pretty baisic limb function (radius = the length of the are from shoulder to elbow)

the lower arm can be placed at the elbow joint (in step event jump to elbowjoint.x,.y)


so there ya have it, the same function can be done for the rest of the joints.
all that we need now is to figure out how to make thus function work for MULTIPLE objects. and of course the code that states the ragdoll effect for each limb as stated above.


we can do this if we work as a team :angry:

0

#22 User is offline   viestituote 

  • The Moinen
  • Group: GMC Member
  • Posts: 84
  • Joined: 22-October 03

Posted 19 February 2004 - 05:49 PM

Quote

>>viestituote the link opens the file as a html file
'save target as' alse refere to the html tag (anchor)
can u fix that?

I added the other link.. it should work correctly.

>>SSNautilus
um... you could try to move the origin of the sprites to get the limps actually seperate from the torso... It's not very realistic but it looks somewhat like it.

We can problaly never (never say never) achieve "real" ragdoll physics with GM, but we could use something like this, just a bit modified...

The next thing we could try to add is, like SSN problaly tried to say, is to get the previous part of the rope also affect to the motion.

Currently it just keeps to part in the range of 100 from the next part of the rope, I originally had some sort of code in it that would do this, but the effect wasn't very good... I'll try again today...

What I can now think of, is something like gringo said, to have a direction and force variables. In each step, the gravity is added to the force, to direction 270. Then we calculate how much we must add force from adjected parts... hmmm... We need the same algoryth as the motion_add(dir,spd)...
Anyone got it?
0

#23 User is offline   viestituote 

  • The Moinen
  • Group: GMC Member
  • Posts: 84
  • Joined: 22-October 03

Posted 22 February 2004 - 06:02 PM

:rolleyes: Jay! I've made an example! This time it's very life-like rubber-rope with a giant iron ball at the end! You can swing it! whoa!

Anyhow... I made my engine again completely, it's not optimized nor commented but at least it proves that natural-looking IK joints are possible with GM... I used about 10 lines of code in the step event... so it's not very heavy either...

This example doesn't include collision, that's my next project... You may play with it... Maybe you can get the idea of the engine.

Download here http://kotisivu.mtv3...gdoll_rope2.gmd

So, now it's proven that some kind of fake ragdoll physics are possible with GM. I'll still have to improve it, though...
0

#24 User is offline   King Stephan 

  • www.gameboxsoftware.com
  • Group: GMC Member
  • Posts: 734
  • Joined: 10-October 03

Posted 22 February 2004 - 09:41 PM

That's funny, I made practically the same thing only mine's a bit smoother.
http://www.geocities...yer/ragdoll.zip
0

#25 User is offline   torrobinson 

  • GMC Member
  • Group: GMC Member
  • Posts: 13
  • Joined: 28-October 03

Posted 23 February 2004 - 01:53 AM

Theres nothing in the zipped file ^_^ :rolleyes: :lol:
0

#26 User is offline   Kornbizkit1718 

  • Wanderlust
  • Group: GMC Member
  • Posts: 274
  • Joined: 04-October 03

Posted 23 February 2004 - 04:35 AM

Dude, stephen, the link works n all, but its like 0kb big...
0

#27 User is offline   viestituote 

  • The Moinen
  • Group: GMC Member
  • Posts: 84
  • Joined: 22-October 03

Posted 23 February 2004 - 08:18 AM

Whoa it is the same! The code princible is just the same! Only difference is that in my example there's more parts to the rope and the attributes are a bit different (gravity, stffines, lenght, friction etc.)...
0

#28 User is offline   viestituote 

  • The Moinen
  • Group: GMC Member
  • Posts: 84
  • Joined: 22-October 03

Posted 23 February 2004 - 03:55 PM

Hmm... I can't figure this out... How can you make 2 objects bounce off each other realisticly depending on objects' mass, elastisicy, speed, direction and maybe rotation.

Anyone got any example of this? I think you could find some papers about this from Google, but as my school is finnish, I can't really understand sience-english so easily (if someone finds something, post the link, I'll use dictionary) as you might.
0

#29 User is offline   Zero_Point 

  • GMC Member
  • Group: GMC Member
  • Posts: 34
  • Joined: 28-January 04

Posted 24 February 2004 - 04:24 PM

Hmm... It'll probably require a special script with various algorithms to process how the certain variables play a part. For example, it you entered 10 as a variable for speed and 15 as a variable for mass, and then entered 4 as a variable for elasticity, you can set various motion actions to move the objects based on what the scripts' alogorithms produce.
0

#30 User is offline   Lyndon 

  • GMC Member
  • Group: GMC Member
  • Posts: 78
  • Joined: 05-February 04

Posted 24 February 2004 - 07:53 PM

Maybe this will help you guys

http://www.dynamicdr...ndex13/band.htm
http://www.dynamicdr...13/trailer2.htm

Indeed
0

#31 User is offline   viestituote 

  • The Moinen
  • Group: GMC Member
  • Posts: 84
  • Joined: 22-October 03

Posted 25 February 2004 - 06:16 PM

Lyndon, on Feb 24 2004, 10:53 PM, said:


:huh: actually, my example is based on the second one. I saw it on some page by accident, and then converted into GML....

But unfortunately these don't include collisiond between two objects... I made some experiements based on Boomed32's car physics example. It used the built-in bounce and reduced the speed based on the direction change.. This didn't work out very realisticly...
0

#32 User is offline   King Stephan 

  • www.gameboxsoftware.com
  • Group: GMC Member
  • Posts: 734
  • Joined: 10-October 03

Posted 27 February 2004 - 02:42 AM

I made mine myself. I simply loaded a bunch of coordinates into an array, and made them move toward the next with some inertia, draw the lines between them, and a small ball on the end. For some reasoin people can't download mine (right click> save target as ^_^ ).
0

#33 User is offline   sxclimax 

  • GMC Member
  • Group: GMC Member
  • Posts: 17
  • Joined: 14-December 03

Posted 27 February 2004 - 04:41 AM

It does provide collisions. Move your cursor to the side of the screen. It collides with the wall of the browser window.
0

#34 User is offline   SSNautilus 

  • S.S.Nautilus
  • Group: GMC Member
  • Posts: 137
  • Joined: 10-October 03

Posted 28 February 2004 - 03:25 AM

I've fixed the sprites - so they now better align than before. I have also used a jump_to action to make the sprites allign with each other, and a collision event so they all collide with walls.

Its not much, but a basic man_object. And needs some work. I have rotated all sprites (counter-clockwise x 16 frames) except HEAD and CHEST, as they were making the file beyond my servers uploadable limit of 900KB. :o You press space to change directions - but do see the default collisions first.

http://www.angeltowns.com/members/ssnautil...sc/ ragdoll4.zip

I've noticed one thing about all the 'rope' examples, is that none of them take into account the fact that when things move on joints, they always rotate.

Now, doing 2D ragdoll effects may not require full fledge physics, but maybe a neat algorithm to actually PIVOT several objects - depending upon the 'impact' and direction of the neighbouring objects.

For example.

Logically speaking, if an object gets shot in the torso, the torso/abdomen will most likely be 'pushed' furthest back, and the limbs would follow.

If an object gets shot in the head, the head goes furthest, the the body follows, and limbs probably go in any direction.

Essentially, what would be needed is that a variable check that is constantly exchanged between all connected body part (or global.vars) to check for the following:

(a) Impacted object.
(B) Impacted objects collision direction.
© Impacted objects pivoting angle.
(d) Connecting objects/limbs corresponding pivots, and 'deduced' direction.
(e) Assigning logical weights_vars to objects, and amounts for frictions/grav
(f) Calculating how much 'energy' is actually 'absorbed' to 'push' the impacted object - then dividing the remaining 'energy' of impact within the rest of the body.

However, this all may sound a bit complex, and cumbersome, so lets step-back and start at the PIVOT basics first:

http://www.angeltowns.com/members/ssnautil...bat_physics. zip

Here's a starter. Press space and a bat_object is created. They all fall down, and hit the pins on the way down. Can anyone figure out a way to make the bat_object pivot in the CORRECT direction when it hits the pins? Something like the balance scales. They should also respond correctly when they collide with each other.

Happy pivoting! :P
0

#35 User is offline   viestituote 

  • The Moinen
  • Group: GMC Member
  • Posts: 84
  • Joined: 22-October 03

Posted 28 February 2004 - 10:58 AM

>>sxclimax
Yeah, but all it does is to reverse the hspeed and multiple it by 0.75, we are talking about a bit more complicated physics :medieval:

>>SSnautilus
Those links don't work, gives me an error.

But, as I can see from your post, we are getting close to the solution, I think I'll try to add variables heading_direction and rotational_force.
Then, every joint of a object has it's direction. So, when an object which is connected to this object's joint1, which's direction 90, the rotational_force is changed to move thowards it... Or something... whoa
0

#36 User is offline   ikbendirk 

  • GMC Member
  • Group: GMC Member
  • Posts: 30
  • Joined: 01-November 03

Posted 28 February 2004 - 11:52 AM

currently i'm making a armature demo... it hasn't much to do with ragdoll effects yet, but its a start...

it isnt working very good yet, but at least you can have a look at the code..
SSNautilus said i should give some ideas about the ragdoll, so, here they are! :) well after we have completed a fully working (and skinned ;) ) armature, we can go and think about forces...

about the armature, actually it is very simple: there are n bones, and bone n-1 is the parent from bone n... some rotation calculations ofcourse... and thus there are two x's and y's for every bone: the top and the bottom. the top is always connected to the bottom of its parent (except for the first one) and the bottom is calculated with (co)sinus, radius and top-x,y.

after we've created an armature we must skin it: i have not much experience bet lets have our thoughts about this one; the image rotates in the centre, so we must skin it at the centre of the bone.. so:
x=(x1+x2)/2, y=(y1+y2)/2

well ofcourse the image is now still shifted, so the image-width,height should still be substracted which gives us:


x=(x1+x2-image_width)/2, y=(y1+y2-image_height)/2
i hope someone can find some use with this knowledge :medieval:

oh i almost forgot!
my armature demo click here

[EDIT, 1 March] [Broken links corrected at 2 March]
as posting takes too much time for me, i'll keep editing until i at least get some replies :D i fully completed the demo for now.. there is only one problem with rotating the bones; at first i dont know what's the easiest: to refer to relative rotation or not.. well as for the error, it occurs while more bones are childeren from only one parent... can't figure what the problem is yet :) but i guess it can already be used for some ragdoll tests.... any volunteirs :D?
Newest update

This post has been edited by ikbendirk: 02 March 2004 - 02:42 PM

0

#37 User is offline   Yani 

  • GMC Member
  • Group: GMC Member
  • Posts: 48
  • Joined: 12-January 04

Posted 02 March 2004 - 12:34 AM

Viestituote, your example is a good start, but I would've tweaked it a bit more before releasing it. I have made a similiar example. It has a real-looking rope, you only need to specify the length of it. It even collides to different shapes almost correctly. The only thing I was too lazy to make was the inertia/momentum thingy.
Well.. actually it had my own quick version of it^^ the rope parts at the bottom were heavier than the parts at the top. It even was believable at times, but all it could do was when I let the rope loose, the part with nothing below it fell down and dragged the end of the rope on surfaces if there was enough loose rope.

Oh, and ragdolls are quite possible. The physics' realisticness isn't that important on below 64x64 character. Ever played soldats? It has a ragdoll system although it isn't that precise, it looks cool. I think I'll try to make an example of it sometime.
My RPGM-project is taking all my GM-time. Someone else might make it before me but who cares! :D

Peace out

P.S. Näkeepä täällä näköjään suomalaisiakin... hyvä juttu :)
0

#38 User is offline   Yani 

  • GMC Member
  • Group: GMC Member
  • Posts: 48
  • Joined: 12-January 04

Posted 02 March 2004 - 12:36 AM

eeh... hehe... didn't notice page 2 :)
well.. think of the previous post as an extension to page 1 :D
0

#39 User is offline   viestituote 

  • The Moinen
  • Group: GMC Member
  • Posts: 84
  • Joined: 22-October 03

Posted 02 March 2004 - 04:53 PM

>>>Yani
Yeah, it should be trimmed a bit... When I made it, my old-slow computer was running Opera, Messenger, ICQ, mIRC and some other "heavy" programs, not to mention the internet connection, so it didn't run at very high speed and as so the program didn't record my mouse movements as fast as it should've.
I noted it later, though...

Ah, I admit! I was too hasty with it! :) ... anyway... it works kinda OK if you don't make any fast moves. haha.
0

#40 User is offline   Pogo708 

  • GMC Member
  • Group: GMC Member
  • Posts: 107
  • Joined: 15-November 03

Posted 04 March 2004 - 07:50 PM

Hmm... Well, it's not perfect, but it's a start.........

Stick Physics

Click to set a stick. Sometimes it gets stuck, but does anyone want to modify it?
cb_x and cb_y are for the center of balence.
0

Share this topic:


  • (21 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users