[Closed] rotate like lookat
I have two objects.with script i want to rotate first object like lookat to secend object.
Hi, for Z-axis direction it’s really simple:
obj.dir = target.pos - obj.pos
for the other axes, it can be illustrated for example by something like this (this is for the X-axis):
vec1 = normalize obj.transform.row1 -- X-axis vector
vec2 = normalize (target.pos - obj.pos) -- direction vector
rotate obj (quat (acos(dot vec1 vec2)) (cross vec1 vec2))
Tank you for your answer; what about this:
—————–CodeStart—————
A=teapot pos:[50,0,80]
B=teapot()
angles = atan2 (A.pos.x-B.pos.x) (A.pos.z-B.pos.z)
about B.pos rotate B angles y_axis
—————-CodeEnd—————–
3dsmax lookat have a big problem and icant use it in my rig,im going to make a better and custom one,i think spline and lookat have a same problem
What problem exactly are you talking about? If I would create my own lookat I would use an expression controller and not a mxs controller because it’s faster but I can’t think of an idea of why to do that and not use the lookat controller.
You right,i just use mxs to create cuatom rig.but for custom lookat i use expression.one of problem with lookat is when we want to mirror it.just run this script an try to mirror it in x axis .
Obj=teapot
P=point pos:[0,0,200]
R=circle radius:50
L= obj.rotation.controller= lookat_constraint()
L.appendtarget p 100
L.target_axis=2
L.upnode_axis =1
L.stoup_axis=1
Obj.parent=p.parent=r