I understand pieces of them, but I read all these questions on here about "How do I get component X to communicate with component Y?" and think to myself: Man, that looks like more pain than it's worth
I don't understand the cache-coherency thing if, say, each sprite component has to do a key lookup into a transform component and the script component has to modify the sprite state component
and then the render handles turning 3D array into triangles
or like, not using game-world coordinates for rendering
if all your rendering coordinates are player-centered, you don't randomly have floating point errors when you're too far away from the center of the world even if you're using a low number of bits.
I suppose that depends on the effect you're going for
If you want it to look natural--up to the point that your ragdoll is flung through the air/against objects--you'd better animate the limbs along with the torso.
@TreDubZedd In that case, how should they actually be moved? Afaik, most physics engines (I'm using Box2D) aren't good at handling moving the bodies around directly. They expect you to apply some force to the bodies, and the physics engine will calculate their next position.
Doesn't moving the limbs alongside the animation imply you have to set their position directly, at every frame?
If I were doing it, I'd probably have (at least) two states: ragdoll_enabled and its opposite (something like programmer_controlled). I'd only allow the physics engine to operate on individual limbs when ragdoll_enabled is true.
So like in Unreal Tournament, the character models are rigid and controlled until you die, then all of a sudden, your limbs are loose and free to do whatever
@TreDubZedd But say for example you wanted something like this: you have an animation where the character raises its arm; a bullet is fired and it should actually hit the arm at the position the animation indicates it is; if the limbs are not actually in the position indicated by the animation, the bullet might not hit the arm, even though the action as seen on the screen makes it seem like it should have hit it.
@TreDubZedd A clearer example: if the physical body is static, and it's standing up right all the time (for as long as the character is alive), then even though the crouching animation is being played, his body still gets very high exposure to bullets.
This means I have to somehow move the body alongside the animation, but how do I do that in a way that doesn't mess up the physics simulation?
Ohh, hmm. So you have an animation that is a single graphic, then you are modeling the animation again in box2d with all the limbs and want to know how to sync the two?
The problem has two sides, too: (1) how do you make move the limbs without breaking the physics simulation; and (2) how do you architecturally implement communication between the animation and physics systems, cleanly.
Perhaps your "animation" should be guides for physical forces--apply forces to each limb in order to get it into the desired position for the end-result animation.
Normally, I'd think you'd make a box2d figurine, have it move the way you want it to, and add graphics for each individual limb (one for the head, one for each leg, one for the torso, one for each arm, etc)
usually the limbs are controlled by box2d as separate objects. if you've got a pre-rendered animation, then just use that and redo your collision detection code for that, don't try to force box2d to follow your animations
@JohnMcDonald I did say it's skeletal animation, so I'm talking about realistic leg movement while walking, realistic arm waving, maybe protecting one's face from an explosion by covering it with a hand, etc.
@JohnMcDonald Facial expressions are easily done as different sprites for the same body drawn at different keyframes.
When you're alive, the walking, running, rolling, jumping, aiming, shooting animations are all controlled by the skeleton, and different images are sometimes drawn over the limbs. When you die, the skeleton turns into a ragdoll, so that's proof that they are using a skeleton for all of that
@PaulManta Actually you should only have one collision detection system. Either use separate objects for the limbs and figure out how to recreate your realistic animations doing that, or drop box2d for collision detection because it's not going to sync up with your realistic pre-rendered animations
@JohnMcDonald Not exactly what I would call 'fine' animations. Can you do anything remotely close to Outland (youtu.be/8Ff-I6x2KSA) without prerendered animations?
@JohnMcDonald Skip somewhere at the middle, I guess. Look at how the character is moving.
@JohnMcDonald The most impressive animation I've seen done solely with a physics engine is from the Box2D testbed, the Theo Jansen Walker. It was a pretty amazing feat, using motors and whatnot to actually achieve the effect.
Physics-only animations are good for robotic stuff. You can't really do fluid animations without pre-rendering them.
I was pretty sure the walker was just an example of how you could use motors to make something move. I don't think the only way to move stuff in box2d is to apply a force, is it?
@JohnMcDonald Two reasons: (1) the crouching example again, collision should (ideally) occur with the character being in the position indicated on-screen; and (2) so you can easily switch to ragdolls when the character dies.
Well, point #1 can be handled in other ways than to have a skeleton set up, but the only way (that I know of) to handle #2 is to have images drawn for every limb
@PaulManta Frankly, I expect the character model in Outland uses some sort of basic skeletal rigging, or it's just well animated and who cares if a bullet hits a limb or doesn't
@thedaian I'm not trying to copy Outland. It might use skeletal animation as well, but it certainly is pre-rendered skeletal animation. There's no way they achieved that by applying forces to limbs.
@JohnMcDonald How I store my data on disk is not yet fully decided, but it will be soemthing along these lines: a sprite for each lib, and each sprite has an associated shape (the shape is used by the physical simulation).
And a slightly related question: how does the character stand up? Kinematic bodies and collide with static ones (the ground), so should I have a platform tied to the character's main body?
I don't know how easy it would be to make animations like the ones from Outland, but I also doubt that Outland used animations based from a skeleton like this
we create all bodies and constraints for the ragdolls in the frame our pawn dies, and its not on a modern pc, its on 5 years old platforms, xbox and ps3, if it works there, its gonna be fast enough on a todays PC :p
yeah, especially if it's only something that's going to happen once or twice during a frame, and not every frame, the speed should be alright (unless it's a behemoth)
@JohnMcDonald It is possible to combine the two. The Outland character has a cape that is certainly "frame-based", though it would be just a bone with different sprites pasted on top of it at different keyframes.
tbh, I'm not sure I'd actually have a bone for the cape if you were going to also have "frame-based" animation for it. I might include it with the torso frames
@JohnMcDonald Yeah, but that's not what I do. I might use that as the "support body" (the one I actually move around, while the limbs and torso are just attached to it).
There's one last thing I'd like to ask about: how to actually organize the files in the game's directory. As I said, for every sprite I have a body (forearm.jpg has forarm.body) -- that's the easy part.
Then I should probably have some animation files: walking.anim, jumping.anim, etc, that reference the sprites and define keyframes.
How can I (and should I) have a separate character.model file that references the forearm.body-type of files to actually define the final body of the entity.
I'm thinking this would ensure that my animations are all coordinated (one doesn't have more limbs than the other, and it also makes mapping of the animation to the physical limbs easier during initialization).
HTML5 & Javascript RPG
200 x 200 map
Map generated from heightmap
6 types of tiles
24x24 px tiles
Example Map
Ok, so I am writing a game in JavaScript with HTML5, in which a 200x200 map is generated from a randomly created heightmap. I have a fairly simple algorithm which extracts the c...