Search code examples
animationactionscriptflash-buildermayaaway3d

Away3D and FlashBuilder - Character interaction


I am building a very simple game with Away3D and I currently have a character imported from Maya and objects for him to hold.

The question is, how can I correctly position an object at the character's hand if he is constantly being animated? (breathing, walking, etc)

Thanks!


Solution

  • It depends on the animation you are using.

    1) Skeletal based animation will have joints for each area of the avatar that moves. You can extract joint transforms from the SkeletonAnimator globalMatrices property - this returns a concatenated array of the 4x4 transform matrices for each joint transform from which you can grab the transform for the joint you want to use as the attaching position

    2) Vertex base animation uses geometry objects for each frame and interpolates between them. Because this calculation is done on the GPU, you will need to recalculate any interpolation for a vertex (or set of vertices) yourself before you can create a position. this can be done by accessing the activeState property and casting as a VertexClipState, then returning the currentGeometry and nextGeometry properties. It less straightforward than skeletal animation and you'll also have less information about the avatar position (no rotation info) making things a little trickier to have things like avatars holding swords etc but it can be done.