Colobot Forum - International Colobot Community

Full Version: Advanced targeting
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I curious  - how exactly direction function works?
May some one share his/her own example of code, in which used only position of me and target, and their YAWN,ROLL, and so on.
direction() returns returns value which needs to be inserted to turn() in order to make bot face certain position. Ex:


Will make bot turn towards item

But I think you might think about object's information, and not instruction. In that case I honestly can't help, since I never really used .direction, .yaw and .roll
It's something similar to this (untested, may not work as I wrote it from memory):
float object::direction(point pos)
    float x = atan2(pos.y-this.position.y, pos.x-this.position.x)-this.orientation;
    if (x > 180) x = x-360;
    return x;
it works perfectly! You have a good memory))