Colobot Forum - International Colobot Community
Advanced targeting - Printable Version

+- Colobot Forum - International Colobot Community (https://colobot.info/forum)
+-- Forum: [Archive] New forum (2015-2019) (https://colobot.info/forum/forumdisplay.php?fid=76)
+--- Forum: Colobot: Gold Edition Basics (https://colobot.info/forum/forumdisplay.php?fid=58)
+---- Forum: General (https://colobot.info/forum/forumdisplay.php?fid=59)
+---- Thread: Advanced targeting (/showthread.php?tid=812)



Advanced targeting - clop1000 - 07-02-2016

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.


RE: Advanced targeting - radioactivity - 07-02-2016

direction() returns returns value which needs to be inserted to turn() in order to make bot face certain position. Ex:

turn(direction(item.position));

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


RE: Advanced targeting - krzys_h - 07-02-2016

It's something similar to this (untested, may not work as I wrote it from memory):
Code:
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;
}



RE: Advanced targeting - clop1000 - 07-04-2016

it works perfectly! You have a good memory))