How to make an object rotate around the tracking axis?

is this possible? using a track to actuator and a motion actuator does not work, is there any other way of doing this?


import bge
cont = bge.logic.getCurrentController()
own = cont.owner
from mathutils import Vector


if 'target' not in own:
    own['target']=bge.logic.getCurrentScene().objects['TargetCube']
else:
    target = own['target']
    vec2 =own.getVectTo(target)
    
    own['rot']+=.1
    if own['rot']>=3.14:
        own['rot']=0
    own.alignAxisToVect(Vector([0,0,1]), 2,1)
    own.alignAxisToVect(vec2[1], 1 ,1)
    own.applyRotation((0,own['rot'],0),1)
    

tested and working (thanks sdfgeoff for your help with this stuff in the past)
untested, but should work.

Attachments

WorkingExample.blend (407 KB)