Track to problem

Whats up. I’m having trouble tracking to an object correctly. I want it to track 2d to another object, but sometimes the tracker object is on its side, and the track doesnt work. Track 3d is not an option, because then the object is alwasy orientated +z local facing +z global. This will cause the track object to go into the ground. 2d seemed more promising, but it still wants to track with a global z. can anyone help, or guide me in the right direction.


track problem.blend (132 KB)

Bump. I have been trying all day to figure this problem out. I really need help. My game will truly suffer without this. I got close with a script used by PhilB and Social. I did some editing and came pretty close, but the answer still is no where in site. I hope some one can help. I left a file with my latest progress. I think the file is self explanitory.


align to vector.blend (157 KB)

why don’t you just create an actuator with the type “Edit Object”-> “TrackTo” and put in the Cube.003 as target object? A simple “AND” controller is enough then. It will only follow in 2D.


I have tried that. If you look at the first example blend it shows the problem. the 2nd one is close to the result i am looking for, but they still spin off the axis i want them on. I want their +z to keep its axis facing the blue arrow, while it tracks to the target. I basically need a 2d trackto but in any orientation.

Run this little python script to make local z face global z.

own.alignAxisToVect([0,0,1], 2, 1)

yea i tried that but that is what i dont want it to do. I dont want to to point global. That is basicly the same as the trackto actuator. I want it like the 2d track to but local. i have an updated file that mimics what i want, but it is just to show my idea. I dont like this file because it is a different version of the same script. I need it to be one scrpit. Also this will only work on a cube i need it to work in any orientation. but the way the track is what i need. It is local, or atleast it seems that way.


align to vector.blend (157 KB)

Just change what vector you want the axis to point in, it looks like in your .blend you want that object to have its +z axis point in the -y direction so the vector would be [0, -1, 0]:

own.alignAxisToVect([0,-1,0], 2, 1)

Just make sure you run that after all the other tracking is done.

I ended up solving the problem. I tweaked a script Social made for PhilB. Thanks Social.


align to vector2.blend (167 KB)