Using MotionBuilder’s Python To Have One Object Follow Another

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

##Find The lTarget Object In Our Scene
lFollower = FBFindModelByLabelName(lTarget)
##Set Animated To Be True For Tanslation And Rotation

##Copy The FCurves From The Leader On To The Follower
##Local Translation X
##Local Translation Z
##Local Rotation Y

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.

Add a Comment

Your email address will not be published. Required fields are marked *