===== Blending animations for 3D objects Application Sample ===== This example is based on a previous [[interact_tutor|interactive scene]] tutorial sample. We will use base code for 'interactive scene' sample and modify only the body of 'setupNavigation" function. Cast3D version 0.97 or later is required for this sample. ==== Major Steps ==== There are few step are necessary to combine motions: ==== Create Blender object ==== import cast3d.tracks.MotionBlender; // Lets make an instance of motion blender var mixer:MotionBlender = new MotionBlender( "motion_blend"); ==== Add Motion Group tracks to blender object ==== We are going to blend two motion groups. First we need to find track by id in node's track list. motion group to blend with is "lowerBack_motion" track_id = "lowerBack_motion"; we need to find "lowerBack_motion" track first, which is a 'walking' animation track for each ( track in node.tracks) { if (track.id == track_id) break; track = null; i++; } then remove it from node's track list to prevent it from being animated if (track) { node.tracks.splice(i,1); track.enabled = true;} Next, we add it to blender, with weight = 0.5, which means 50% influence from this motion will be applied to node mixer.addTrack(track,.5); Same thing with another motion group "lowerBack_motion539", which is 'waving' motion track_id = "lowerBack_motion539"; i=0; for each ( track in node.tracks) { if (track.id == track_id) break; track = null; i++;} if (track) { node.tracks.splice(i,1); track.enabled = true; } mixer.addTrack(track,.5); ==== Add blender to node's track list ==== we need to enable mixed, by default all tracks are disabled mixer.enabled = true; and add to tracks node.tracks.push(mixer); ---- Full source for this function could be [[blendsource|found here]]. ==== results ==== So, if done it right you should see something like these: