trackTo and alignAxisToVect problems

I’m making a game where you run around a planet like Mairo Galaxy, and I’m using the track-to actuator to point the character in the right direction when running. (like in Cray’s third person template)

The problem is when you’re upside down the trackTo actuator doesn’t work because one axis is pointing up globally at all times.

I need to track an object rotating around the local z axis.

alignAxisToVect works but has a very undesired slow ramping up effect.
How can I get rid of this effect and make it work like the actuator?

I’ve been trying to do this manually in python but I’m lost,


align axis delay.blend (138 KB)

I think its to do when you try to track to something that is directly behind it, if you hold left and right so that the object doesn’t point directly left and directly right it has no delay.

I have never seen this before though.

hmm…where do you track the character to anyway? Try adding a distance constraint actuator to the character so that his feet will always be pointing to the ground

Track 3D was fixed in 2.49, wasn’t it?

@ PhilB

The “factor” argument for alignAxisToVect() must be 1 for the actual alignment to occur. Something like 0.5, for example, will just get you half way, and then another half, and then another half, and so on into infinity -> you’ll never actually align with the pursued vector.

I would not use alignAxisToVect() for tracking, unless it needed to be instantaneous tracking. What you should do is get the vector to the object you wish to track, and actually modify the orientation matrix to perform a slow rotation aligning with that vector.

This would require some bothersome math, of course, which is why it would probably be best for you to post a simple .blend that shows the track-to actuator failing in the manner you described.

If it’s some isolated case, it would probably be easier (and more efficient, performance wise) to write python to avoid that particular case, than to reimplement the track-to actuator in python.

Jinthan, The tracking is for player movement, you can download the third person template if you want to see an example.
I’ve got a video of my current progress here
Most everything is worked out except for this tracking issue.

Social, Thanks for the info. I thought the “factor” argument was like the “time” for the trackTo actuator, wish it was…
btw, I’m also using the planet gravity method you posted here, works great :slight_smile:

and actually modify the orientation matrix to perform a slow rotation aligning with that vector.
This is where I’m stumped,
I’ve been trying to figure this out for a while now, I’m going to try using an IPO animation rather than tracking and see how that works.

Here’s a blend showing my problem.
The first cube is using the track-to actuator and when it moves more than 1/4 way around the planet it freaks out,
because the z-axis is not pointing up?


planet orientation problems.blend (344 KB)

It would seem that the rotate_player script is interfering with the track-to actuators.

I made an example that does what I think you want (attached).

It’s not using any complex math; it just uses angular velocity to turn to either side, and then aligns when the angles are close enough.


planet_track.blend (336 KB)

Thank you! This works beautifully!

I still had a little problem of rotating left or right depending on which way is the shortest, but I got it working.

Thanks a lot Social!


Ha, ha, ha!

Wow, you’re welcome man.

That looks awesome!