Notifications
Clear all

[Closed] control one object with another

im tryin to learn max script better, i wanted to see how to ie use the rot of a sphere y to control the trans of a box in X

here is my sudo code


 --Sphere rotate on Y to control box X trans
 
 rot = rotate Sphere01 (angleaxis   [0,1,0])
 
 move Box01 $ [(rot),0,0]
2 Replies
 eek

(
local sc = float_script()

sc.addtarget “zRot” $sphere01.rotation.controller[3].controller

sc.script = “degToRad zRot”

$box01.pos.controller[1].controller = sc

)

something like this roughly (not at my desk)

Here’s a really crude way of doing it –


     rollout test "Test"
     
     (
     timer clock "testClock" interval:1
     
     local newPos
     
     on clock tick do
         (    
         childPosX = ($Sphere01.rotation.y)*10 -- added *10 to exagerate movement
         childPosY = $box01.pos.y
         childPosZ = $box01.pos.z
     
         newPos = point3 (childPosX) (childPosY) (childPosZ)
         
         in coordsys world $box01.pos = newPos    
         )
     )
     createDialog test 200 100
     

I used a timer to update the viewport, but that is another really crude way of doing this.

But at least you see how to get old of the specific xyz values from one object and apply it to another.