03-18-2016, 07:04 PM
After you detected object using radar(), you can access its orientation easily:
Angle in degrees can be used in sin() and cos() to compute Cartesian direction. In standard math:
dx and dy will be the change you need to apply to position. radius is the distance from the object. You can add dx and dy directly to base position and obtain where you need to move:
I'm not sure if it will work like this in CBot because coordinates or orientation might be different, so you might have to test this and adapt if necessary.
Code:
object item = radar(Target2);
float angle = item.orientation;
Angle in degrees can be used in sin() and cos() to compute Cartesian direction. In standard math:
Code:
float radius = 5.0f;
float dx = radius * cos(angle);
float dy = radius * sin(angle);
dx and dy will be the change you need to apply to position. radius is the distance from the object. You can add dx and dy directly to base position and obtain where you need to move:
Code:
point pos = tar2.position;
pos.x += dx;
pos.y += dy;
I'm not sure if it will work like this in CBot because coordinates or orientation might be different, so you might have to test this and adapt if necessary.
"After three days without programming, life becomes meaningless."
~The Tao of Programming
~The Tao of Programming