obj.alignAxisToVect VS. TrackTo Actuator

There’s a disparity between the two when it comes to tracking an object in 3D space.

alignAxisToVect does well until it gets rotated upwards, then rotated horizontally, then it gets all weird. Is there a way to get the alignAxisToVect function to act like the TrackTo actuator? Or are there some things I’m missing.
Blend file here:
M.blend (684 KB)

When you align to axis you just align the axis. What you expect is that the roll around the axis is aligned too. With your method it is not the case.

The trackTo actuator uses an up-vector to align the roll (defining what is up).

In your code you need to align at least two axis. One for up (first) and one to track forward (second). I suggest to add alignment for up to your code.

Be aware: these vectors should not be parallel. In that case the roll can be anything.

Ohh… Didn’t know you could align more than one Axis at once! I thought you had to do all the calculations within the parameters of a single alignAxisToVect Function. :stuck_out_tongue:

It’s working as intended now! Thanks!