Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What object is this cross in a circle?
#7
After you detected object using radar(), you can access its orientation easily:

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


Messages In This Thread
RE: What object is this cross in a circle? - by tomaszkax86 - 03-18-2016, 07:04 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)