Weird lookat problem

this one is creeping be out:

i have a few actors in my game. these actors can shoot fireballs. now, if i let them throw ms3d-objects, everything is fine. if i give them md2-models, they shoot downwards instead of at me. if i give them primitives like a cone, they shoot at me again.

WHAT THE ?!?!?!?

i'm not talking about the model's orientation, it's the direction of the projectile where it's flying to. i don't get it. i apply exactly the same rotation, no matter what kind of model it is. if i randomly rotate the model itself, the rotation is applies correctly. if i simply copy the actors rotation, the projectile is flying correctly. but if i do this:

  public void turnTo(final Vector3f p_target, final boolean p_adjustYLookAt) {
    assert !Float.isNaN(p_target.length());
    final Vector3f l_vector3f = ms_tmp11.set(p_target).subtractLocal(m_boundingHelper.getWorldCenter()).negateLocal();
    if (!p_adjustYLookAt) {
      l_vector3f.y = getWorldCenter().y;

it *should* rotate the projectile exactly to where the actor is aiming at - but it does only work for non-md2-models. i checked it in the debugger - the local rotation of my projectiles is the same for both model types, and yet the md2s are about 90 degrees off course.

any ideas? where should i look at?

…and how do you move it?

public void moveRelativeBy(final Vector3f p_movement, final boolean p_flattenMovement) {
    assert !Float.isNaN(p_movement.length());

    if (p_movement.lengthSquared() > 0.0F) {
      if (p_flattenMovement) {
        final float l_v = p_movement.length();
        p_movement.y = 0.0F;

the movement code can't be wrong - it works for anything else
the aiming code can't be wrong  - it worked a few weeks ago, and i didn't change it

from a logical viewpoint, there can't be a bug. i didn't change anything (i am aware of)

Could it be something with the md2 models being "Z up" and not "Y up"?  Even if you roatate them correctly, maybe their initial state is throwing things off in some way?

You do that lookAt for the local rotation but use the world rotation to compute the movement vector. Probably your node has a parent with non-zero rotation due to the model loading?

no, the parent has everyting at 0/zero/nothing. but after TEN HOURS, i finally found the bug. i changed:

  • set new size
  • get the center of the model
  • lookat enemy


  • get the center of the model
  • lookat enemy
  • set new size

    the md2 model has a size of about 20 and is resized to 2, which means the center moved quite a lot…

    LOL :smiley: }:-@ :// :-o :smiley: :smiley: :mrgreen:

    freaking out