Homing: Angular Velocity vs Vector Normalization

edited February 2012 in Help request
Hey, we're trying to make homing bullets. We tried calculating the angle between the bullet and the player and using orxObject_SetAngularVelocity on the bullets, but they aren't changing course. Is there something else we have to do?

If not, what are we doing wrong?

Do we actually have to use vector normalization, or is there a way to do this with angular velocity?

Comments

  • edited February 2012
    Hah, I was discussing a similar topic with Iarwain yesterday :)

    my current code does use normalization:
    orxVector_Sub( &newForce, target, position );
    orxVector_Normalize( &newForce, &newForce);
    orxBODY *body = orxOBJECT_GET_STRUCTURE( object, BODY );
    orxBody_ApplyForce( body, &newForce, &orxVECTOR_0 );
    

    Doubtless there's a better way, but maybe follow the rules I do: "1: Make it work. 2: Make it good. 3: (If needed!) Make it fast." :)
  • edited February 2012
    For the record: I am hopeful someone else will better answer your questions by the way, I did not really cover anything particularly well :P
  • edited February 2012
    I'm a bit tired, but I didn't make any connection between the use of the angular velocity and normalizing a vector.

    Till I saw, Grey's solution, that is! ;)

    I still don't understand why normalization is really concerned because you could have had any norm on your force vector, but I'll put all that on sleep deprivation. :)

    As for your first question, sonicbhoc, setting the angular velocity will impact the rotation of your object over time, but its speed will remain unchanged. So that won't do much in term of actual homing, just make your bullet face your target at best.

    You might want to have a look at Craig Raynolds' page on steering behaviors.
    It has been an inspiration for many of us for basic steering needs, and it's definitely a must read. Especially the seek & flee one. You can also download his OpenSteer for either direct use or learning purposes. :)

    That being said, if you look at MushroomStew/src/Missile.inl (the Missile::Update() method), I've implemented a very basic homing missile code there that I use in the game.
  • edited February 2012
    Oh yes, I forgot. If you feel courageous you can have a look at PID controllers.
    Some people use them for this kind of tasks though they are known to be a bit tricky to tweak.

    If it were me, I wouldn't go down that road for your use case. Just thought I'd mention it for the sake of learning though. :)
  • edited March 2012
    Thanks, I looked at the mushroom stew homing code. That's probably just what we need! However, I won't be able to look at the opensteer stuff any time soon; too many projects. And Java won't load through this firewall.
Sign In or Register to comment.