Here’s a quick script that I wrote to have one object follow another. The object that follows will do so on Translation (x and y axis only) as well as Rotation (y axis only). This is the type of set up I use often at work for when I have to animate the Displacement of a Character – a common practice in Game Animation.
from pyfbsdk import * ##The Object You Wish To Copy Animation From/Be The Followed lSource = "" ##The Object You Wish To Copy Animation To/Be The Follower lTarget = "" ##Find The lSource Object In Our Scene lLeader = FBFindModelByLabelName(lSource) ##Set Animated To Be True For Tanslation And Rotation lLeader.Translation.SetAnimated(True) lLeader.Rotation.SetAnimated(True) ##Find The lTarget Object In Our Scene lFollower = FBFindModelByLabelName(lTarget) ##Set Animated To Be True For Tanslation And Rotation lFollower.Translation.SetAnimated(True) lFollower.Rotation.SetAnimated(True) ##Copy The FCurves From The Leader On To The Follower ##Local Translation X lFollower.Translation.GetAnimationNode().Nodes.FCurve.KeyReplaceBy(lLeader.Translation.GetAnimationNode().Nodes.FCurve) ##Local Translation Z lFollower.Translation.GetAnimationNode().Nodes.FCurve.KeyReplaceBy(lLeader.Translation.GetAnimationNode().Nodes.FCurve) ##Local Rotation Y lFollower.Rotation.GetAnimationNode().Nodes.FCurve.KeyReplaceBy(lLeader.Rotation.GetAnimationNode().Nodes.FCurve)
Just fill in the “” for lSource and lTarget with the names of the two objects you wish to be affected.
lSource is you leading object
lTarget is your follower object
I’m sure there is an easier way to script this with python, but AnimationNodes in MotionBuilder’s Python seems like a very large topic to cover – one in which I need to research a lot more.
I hope this helps.