currently working on a racing prototype, I ran into a problem using alignAxisToVect. I’m using it to align the car (Z-Axis) to the racing track, so you can drive through a looping. Now the problem is that the race track has to be very highpoly for the rotation to look smooth. I already played around with the “fac” value ( alignAxisToVect(vect, axis, fac) ) which should “Determine the “speed” of the alignment over multiple frames” (found here), but wasn’t pleased how things turned out.
Now my question is, how can I make the rotation (alignment) more smooth without subdividing the race track?
Thanks in advance,
Adding force in the local negative Z direction will make it stick to the track smoothly while navigating the loop…
I am talking about a “simple motion” actuator (or an applyRotation method) used to apply rotations (not forces nor torques). The actuator is not intended to slow down the car, but to turn it progressively into the trajectory. And it would completely replace the alignAxisToVect method, not work in conjunction with it.
So since the heading of your car is in the z-direction, you should set a rotation around either its x or y axis, depending on the geometry of the car body.
I am assuming the actuator is controlled by the player, for example via the keyboard, but may be I do not fully understand your setup.
An example blend file could help.
hmmmm… here’s a thought. You could have an empty at the center of the loop, and make the car track that empty with its +z-axis while it’s on the loop. You’d probably want to separate the loop to make it easier to detect.
With the alignAxisToVect, you can specify what percentage of the way you want it to go toward that axis by adding a number from 0.0 to 1.0 after the other two arguments. At like .9 it will probably be pretty smooth, and get close enough to the target rotation pretty quickly.
First of all thanks for the replies.
I should have mentioned that the looping was just an example, I want the car to align to the floor all the time, that means you could drive upside down at the bottom of the race track as well (without gravity).
@ Captain Oblivion: As mentioned in my first post, changing this value does make the rotation smoother, but it’s still a bit bumpy.
@ mb10: How could applyRotation help in this case?
Here’s an example .blend (move using the arrow keys): Example
So my question remains the same.
Thanks in advance,
Wow, I somehow managed to completely miss that part of your post…
PS turning the speed to about .07 seems to have pretty good results. If you want much smoother than that, you’ll have to have smoother input- either by making a higher-poly track, or somehow snapping the car to a mathematical curve, and setting the track to no collision (I think this is how many modern games do it- that way you can have your graphics be totally independent of your mathematically perfectly smooth track) the trick is, there’s no curve support built into the BGE so you’d have to do it yourself.
I completely misunderstood your problem, actually.
Now it is clear.
Sorry, no suggestions for the moment…