smooth ang-velocity-based rotation to target 6dof / "AI


these 3D maths are driving me nuts :slight_smile: I have my angular velocity code ready in the plane (see - press ‘m’ to set a new target in the plane), plus/minus numerical stability issues… but as soon as the target (the AI should rotate to face) is not in the same plane, weird things happen :slight_smile:

What I want to ultimatively achieve is that, given a new target, the AI should use its angular acceleration to turn to the target, and smoothly “brake” the rotation when facing it (see my code, I start to “brake” when the angle to the target is less than 20 degrees…), while using the shortest possible rotation direction.

Because I want to do/calc other stuff based on this rotation, I cannot just use an Interval (I guess). So it’s just about fixing my vector/quaternion maths, I’m afraid grin

Has someone got a clue for me?

okay, some next steps I did:

replace the “brake function” with:

    def brakeFunc(self, x):
        if x < 0.0:
            return 1.0
        elif x > 1.0:
            return 0.0
            return 1.0 - (x*x*x*x)

and I don’t need a quat and the “look at magic” to get my axis and angle (duh!), just use

        pd = self.dest - p
        axis = v.cross(pd)
        angle = v.angleRad(pd)

…but the weirdness in 3D orientation stays the same. In 1 plane it just works…

Edit: I’m now looking into ODE - easier and more performant anyway I guess - so never mind :slight_smile: