Combining Box2D physics with a "complex" animation

I'm just learning QuickBox2D and...

Let's say I have in my game a baseball player movieclip, a batter_mc with a nested bat_mc, fully animated via timeline.
I want that bat physics works properly with the ball trowed.

So, if I just match the bat_mc x, y and rotation with the x, y and angle of a QuickBox2D object-bat-shaped, the physics doesn't work, because I miss other parameters like LinearVelocity and so on.

Technically x, y and angle, update the object-bat-shaped on screen, matching the bat_mc position, but it is not considered in movement...
How can I solve this?




In my game I have much more complex animations, like a warrior with sword and shield eqipped, able to perform several combos...
Is QuickBox2D/Box2D the right engine to accomplish this task?
After taking a quick look at QuickBox2D I'd have to say that it will probably prohibit you from using the full capabilities of the Box2D engine.

It is a shame that WCK is not fully documented at the time (it is being worked on I think) since it is alot more powerfull then the mini library you showed.

I'd say that the best option is to look into the official Box2D flash release or check out the C++ alchemy port from mayobutter.

As for using animations with rigidbodies you still have to do that yourself, you can ofcourse set the userdata (usually the visual representation) of an object but U still need to control what that userdata is (standing still/running/attacking animation), Box2D only takes care of what happens in the "physics world" not the graphical representation of that world.
Stryke wrote:
Box2D only takes care of what happens in the "physics world" not the graphical representation of that world.


I agree... I'm just looking for an easy way to blend Flash timelined animations (like a fighting warrior) with a Box2D physics world.
Maybe Box2D is too cross platform and generic, and maybe there are other physics engine more Flash-oriented and specific...

Some suggestion?
Using WCK, you can animate your bodies on the timeline if you set the body type to "Animated." As long as your animation is not too erratic, the animation will sync with the physics simulation. If you end up using a different port, you could implement something similar using Kinematic bodies (this is what WCK uses under the hood).
mmh... I took a look here
http://wiki.github.com/jesses/wck/
...and I'm stuck 🙄

Some other tutorial?
eLz0 wrote:
Stryke wrote:
Box2D only takes care of what happens in the "physics world" not the graphical representation of that world.


I agree... I'm just looking for an easy way to blend Flash timelined animations (like a fighting warrior) with a Box2D physics world.
Maybe Box2D is too cross platform and generic, and maybe there are other physics engine more Flash-oriented and specific...

Some suggestion?


Box2D is THE physics engine for flash, you will not find anything better out there.

The easiest way to develop would probably be the WCK kit by mayobutter.

I do not know what you want to make specifically, but for what I hear its something like a 2D sidescrolling fighting game or so, for as far as my knowledge goes WCK can be your engine for that.

But I do warn you, there is no engine that will have a standard definition for a fighting warrior, whatever way you go it wont be 1-2-3 and there it is, doing everything you imagined 😉.
Ok, I followed this tutorial step by step for the third time... and nothing happens.
The only point I did differently is:

Quote:
Open Component Inspector (Shift-F7)
Change ‘Type’ to ‘Static’ (right down the bottom of the list)


because there is no property selectable in the Component Inspector, and when I click on it, CS5 warns
"This feature is not supported by ActionScript 3.0..."

So I change the property ‘Type’ directly in the Movie Clip properties window-> Component Parameters-> Property: type-> Value: Static
.. doesn't work anyway 🙁
The tutorial didnt work for me either, there were some errors and stuff not predicted by the tutorial.
I guess the tutorial was written for an older version of wck.

I think the easiest way to get started with wck is opening the demo.fla and checking out how the levels and symbols are built. Once you see it in the editor, its pretty easy to copy&paste elements to modify them for your own game.
Frnk wrote:
I think the easiest way to get started with wck is opening the demo.fla and checking out how the levels and symbols are built. Once you see it in the editor, its pretty easy to copy&paste elements to modify them for your own game.


for some reason demo.fla still bugged when I test it 😳

Original thread: https://box2d.org/forum/viewtopic.php?t=5070