This is my first attempt at learning LÖVE for a game concept i have
I will be using ragdoll physics to some extent so i tried composing a ragdoll and cant work out exactly how its done
* Are the body x y coordinates used for the top left pixel for the shapes?
* How is the polygon shape used? and can i just attatch multiple single pixel rectangles according to the image shape
* How to spawn another particle system
* Why does the foot sometimes fall off
* Do joints etc interfear with eachother if they overlap?
And lastly
* To animate the characters would the best way be to use timers and set each each position perframe and then create the ragdoll when a certain condition is met?
ragDÖLL Physics Demo
ragDÖLL Physics Demo
http://www.gregkirk.co.nr - portfolio | http://shadowharlequin.deviantart.com - deviantart
http://www.myspace.com/shadowharlequin - myspace | http://www.vimeo.com/themilkfactory - music visuals
http://www.myspace.com/shadowharlequin - myspace | http://www.vimeo.com/themilkfactory - music visuals
Re: ragDÖLL Physics Demo
Yay ragDOLLs!
One thing: the ragdoll's particle-emitting foot falls off after half a minute.
EDIT: But you know that.
One thing: the ragdoll's particle-emitting foot falls off after half a minute.
EDIT: But you know that.
Re: ragDÖLL Physics Demo
haha yeah i know
might that be because the force applied is greater than the default although there's not one set? But then the other foot should fall off too :S
might that be because the force applied is greater than the default although there's not one set? But then the other foot should fall off too :S
http://www.gregkirk.co.nr - portfolio | http://shadowharlequin.deviantart.com - deviantart
http://www.myspace.com/shadowharlequin - myspace | http://www.vimeo.com/themilkfactory - music visuals
http://www.myspace.com/shadowharlequin - myspace | http://www.vimeo.com/themilkfactory - music visuals
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: ragDÖLL Physics Demo
Nice! Some gravity would be nice as well, though.
-
- Party member
- Posts: 215
- Joined: Sun Jan 18, 2009 8:03 pm
Re: ragDÖLL Physics Demo
* Are the body x y coordinates used for the top left pixel for the shapes?
They specify the location of the body, nothing else. Think of it as the center of the body if you will. Shapes that are created for the body have coordinates relative the location of the body. So "body = ...newBody(world, 100, 200); newRectangularShape(body, 5, 10, 20, 4)" will create a body at (100,200) and a rectangle with center at (100,200) + (5,10) = (105,210). The rectangle stretches 20 in width and 4 in height, hence the upper left corner of the rectangle will be (100,200) + (5,10) - (20/2, 4/2) = (95, 208). If you create a rectangle with three arguments, then it will be placed at the center of the body with the second argument as width and third as height, just as the documentation says.
* How is the polygon shape used? and can i just attatch multiple single pixel rectangles according to the image shape
No, you give it up to 8 points that defines a convex polygon. The rectangle is a special case of the polygon shape. To create concave shapes (like the boots of the character), you need to add two different convex polygon shapes to the same body, e.g. the left and the right part of the boot. I would suggest that you add a key that will draw all the shapes on top of the sprites.
* How to spawn another particle system
You're practically already doing it.
* Why does the foot sometimes fall off
Note that you must save references to all bodies, shapes, and joints (until they've been destroyed) or weird stuff happens. This is the reason that it falls off. After you have fixed this, you should no longer create a new mouse joint each frame either. Also, the revolute joint for the left foot is not on both shapes, this can cause some other problems. (the left is at y=90 and the right at y=95).
* Do joints etc interfear with eachother if they overlap?
Overlap? Note though that shapes that do not have a common joint can collide with each other. In particular, the left and right foot can collide. If this is not desirable, you can set the collision masks and categories for the different parts. You may also want to tune the joints for optimal performance, e.g. by changing the frequency and maximum force.
* To animate the characters would the best way be to use timers and set each each position perframe and then create the ragdoll when a certain condition is met?
You can simply have a constant that tells how much power the physics engine has and how much power the animations have (rather than one OR the other), you could even let this be a parameter in the animation pack. Generalizing, the same constants can be used to have multiple running animations. For instance, a "sadness" animation with a weak constant together with a walking animation with a strong constant could reduce in a walk with somewhat hanging shoulders. By setting the constant differently for different parts of the animation (say, body parts), you may also have a walking animation primarily care about the legs and a fishing animation about the arms. Even if the walking cares weakly about the arms and the fishing about the legs, the result should be fairly good.
On another note, for accurate physics, you will want to rescale everything by making it at least ten times smaller, then draw it ten times bigger. This is easy to do on your own but you may also use CAMERA (http://love2d.org/forum/viewtopic.php?f=5&t=419) to do it for you and forget about it.
They specify the location of the body, nothing else. Think of it as the center of the body if you will. Shapes that are created for the body have coordinates relative the location of the body. So "body = ...newBody(world, 100, 200); newRectangularShape(body, 5, 10, 20, 4)" will create a body at (100,200) and a rectangle with center at (100,200) + (5,10) = (105,210). The rectangle stretches 20 in width and 4 in height, hence the upper left corner of the rectangle will be (100,200) + (5,10) - (20/2, 4/2) = (95, 208). If you create a rectangle with three arguments, then it will be placed at the center of the body with the second argument as width and third as height, just as the documentation says.
* How is the polygon shape used? and can i just attatch multiple single pixel rectangles according to the image shape
No, you give it up to 8 points that defines a convex polygon. The rectangle is a special case of the polygon shape. To create concave shapes (like the boots of the character), you need to add two different convex polygon shapes to the same body, e.g. the left and the right part of the boot. I would suggest that you add a key that will draw all the shapes on top of the sprites.
* How to spawn another particle system
You're practically already doing it.
* Why does the foot sometimes fall off
Note that you must save references to all bodies, shapes, and joints (until they've been destroyed) or weird stuff happens. This is the reason that it falls off. After you have fixed this, you should no longer create a new mouse joint each frame either. Also, the revolute joint for the left foot is not on both shapes, this can cause some other problems. (the left is at y=90 and the right at y=95).
* Do joints etc interfear with eachother if they overlap?
Overlap? Note though that shapes that do not have a common joint can collide with each other. In particular, the left and right foot can collide. If this is not desirable, you can set the collision masks and categories for the different parts. You may also want to tune the joints for optimal performance, e.g. by changing the frequency and maximum force.
* To animate the characters would the best way be to use timers and set each each position perframe and then create the ragdoll when a certain condition is met?
You can simply have a constant that tells how much power the physics engine has and how much power the animations have (rather than one OR the other), you could even let this be a parameter in the animation pack. Generalizing, the same constants can be used to have multiple running animations. For instance, a "sadness" animation with a weak constant together with a walking animation with a strong constant could reduce in a walk with somewhat hanging shoulders. By setting the constant differently for different parts of the animation (say, body parts), you may also have a walking animation primarily care about the legs and a fishing animation about the arms. Even if the walking cares weakly about the arms and the fishing about the legs, the result should be fairly good.
On another note, for accurate physics, you will want to rescale everything by making it at least ten times smaller, then draw it ten times bigger. This is easy to do on your own but you may also use CAMERA (http://love2d.org/forum/viewtopic.php?f=5&t=419) to do it for you and forget about it.
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.
Who is online
Users browsing this forum: No registered users and 9 guests