Notifications
Clear all

[Closed] set child object to z=0

I have a node that is parented to an animated node. I want to set the child’s z position at zero throughout the animation. Would this be possible with a script? Alternatively, can somebody tell me how to view World Space in Track View? If I could do this setting the child to z=0 would be simple, I think. TIA, for any assistance.

4 Replies

Originally posted by fgalpern
I have a node that is parented to an animated node. I want to set the child’s z position at zero throughout the animation. Would this be possible with a script? Alternatively, can somebody tell me how to view World Space in Track View? If I could do this setting the child to z=0 would be simple, I think. TIA, for any assistance.

MAXScript generally works with world coordinates when accessing the .pos property of objects, so it is pretty easy to write a script to keep the child at Z=0.

theObj = selectByName()
if theObj != undefined do
for t = animationrange.start to animationrange.end do
at time t with animate on theObj.pos.z = 0

This operates on the current animation segment.
It provides you with a selectByName dialog to pick the object you want to create keys for, then sets the Z coordinate in world space to 0 on every frame.

You can create a MacroScript button by either dragging this code from a script editor to a toolbar, or by adding to the script:

macroScript KetZeroZ category:“fgalpern”
(
–the code from above goes here…
)

Hope this helps,
Bobo

Thanks Bobo, that works. Is there a simple way to modify this script so that it only sets a keyframe every 5th or 10th frame?

Originally posted by fgalpern
Thanks Bobo, that works. Is there a simple way to modify this script so that it only sets a keyframe every 5th or 10th frame?

Change

for t = animationrange.start to animationrange.end do

to

for t = animationrange.start to animationrange.end by 5 do

Cheers,
Bobo

Once again, Bobo you are the man! Tremendous thanks, you’ve saved me hours of work!