Hello everyone,

I make a code which command to a plane to fly in circle, this circle is cyclic. But actually, he moves square by square and i'd like to improve that to make it more swiftly. So whithout square by square, just the start location must be unchanged.

Here actually i have done: the green circle is what i'm looking for.

  1. I know is it possible to make coordinates to obtain the green circle, but not how to code that;
  2. This theoric code probably start to 0 degrees/radian, my plane can come from anywhere (Red square is the target location before to start the round "state"), so the circle must be adapted in consequence, i mean the target location must be the "0 degree/radian".

But is it possible to make a complicated thing ?

I am not entirely sure if I understand the question. But the math is easy enough.

Assuming you have the angle (α) and the radius of the circle (r) then you can obtain the matching coordinates by:

x = cos(α) * r
y = sin(a) * r

And then the velocity direction is the normal of the radius, look at forward

If you need more informations, please ask what you need to understand.
The angle is an unknown, the radius can be determinated manually.

So, if i understand, in practice:

var radius = 100
var pointNbr = 12 # the number of points of the "circle"
var list = []

for i in range(pointNbr):
     var angle = ? # i should be here probably and must add Pi * 2, correct ?
     var pointPosition = Vector2(cos(angle) * radius, sin(angle) * radius)
     list.append(redTarget + pointPosition)

unitPath.append_array(list)

I don't need to use world to map to have a square by square position, just the start and end position (this is redTarget).

But it miss two things:

  1. The direction to follow the circle, if the plane goes from the left, it must make the round from the right to left (anti-clockwise) and the inverse if the plane goes from the right (clockwise);
  2. redTarget will be the "center", it's not i want, it should be in the top of the circle to make that logic (in my draw, the red arrow is the plane coming from).