I think the easiest way is to get a reference to the objects you want to track.
So you will have the transform of each one of them.
You will have to design the type of movement in this case so that they do not chase them in a straight line.
To avoid (surround collisions) I think it could be done using a collider and changing the direction of the ship when the overlap event occurs.
I once made a program with OpenGL. It really seemed like i was sailing in infinite space.
I used a transformation matrix.
You can simulate spherical and cylindrical coordinates using these matrices.
In mathematics, a spherical coordinate system is a coordinate system for three-dimensional space where the position of a point is specified by three numbers: the radial distance of that point from a fixed origin, its polar angle measured from a fixed zenith direction, and the azimuthal angle of its orthogonal projection on a reference plane that passes through the origin and is orthogonal to the zenith, measured from a fixed reference direction on that plane. It can be seen as the three-dimensi...
A cylindrical coordinate system is a three-dimensional coordinate system that specifies point positions by the distance from a chosen reference axis (axis L in the image opposite), the direction from the axis relative to a chosen reference direction (axis A), and the distance from a chosen reference plane perpendicular to the axis (plane containing the purple section). The latter distance is given as a positive or negative number depending on which side of the reference plane faces the point.
Spherical coordinates worked better for me.
So I think matrix mathematics is the solution to your problem.
who saves always has
you just have to copy, paste and learn how to use.
float MRotx[4][4]={//16
{1 , 0, 0, 0},
{0, cos(beta) , sin(beta), 0},
{0, -sin(beta) , cos(beta), 0},
{0, 0, 0, 1} };
float MRoty[4][4]={//16
{cos(fi), 0, -sin(fi), 0},
{ 0, 1, 0 , 0},
{sin (fi) , 0 , cos(fi), 0},
{0, 0, 0, 1} };
float MRotz[4][4]={//16
{cos(alfa) , sin(alfa), 0, 0},
{-sin(alfa) , cos(alfa), 0, 0},
{0, 0 , 1, 0},
{0, 0, 0, 1}};
float MRot[4][4]={
{(cos(fi)*cos(beta)) , ((-sin(fi)cos(alfa)) + (cos(fi) sin(beta)*sin(alfa))), ((sin (fi)*sin(alfa)) + (cos(fi)*sin(beta)*cos(alfa))), 0},
{ (sin(fi)*cos(beta)) , ((cos(fi)*cos(alfa)) + (sin (fi)*sin(beta)*sin(alfa))), ((-cos(fi)*sin(alfa)) + (sin (fi)*sin(beta)*cos(alfa))), 0},
{ -sin(beta), cos(beta)*sin(alfa), cos(beta)*cos(alfa), 0},
(eyex/w), (eyey/w), ((eyez-20-0.001)/w), (escala/100)}
};
float MRot[4][4]={
{(cos(fi)*cos(beta)) , ((-sin(fi)cos(alfa)) + (cos(fi) sin(beta)*sin(alfa))), ((sin (fi)*sin(alfa)) + (cos(fi)*sin(beta)*cos(alfa))), 0},
{ (sin(fi)*cos(beta)) , ((cos(fi)*cos(alfa)) + (sin (fi)*sin(beta)*sin(alfa))), ((-cos(fi)*sin(alfa)) + (sin (fi)*sin(beta)*cos(alfa))), 0},
{ -sin(beta), cos(beta)*sin(alfa), cos(beta)*cos(alfa), 0},
{(objeto->origen->x/w), (objeto->origen->y/w), ((objeto->origen->z-0.001)/w), (objeto->escala/100)}
};
float MTranformacion[4][4]={
{(cos(fi)*cos(beta)) , ((-sin(fi)*cos(alfa)) + (cos(fi)* sin(beta)*sin(alfa))), ((sin (fi)*sin(alfa)) + (cos(fi)*sin(beta)*cos(alfa))), 0},
{ (sin(fi)*cos(beta)) , ((cos(fi)*cos(alfa)) + (sin (fi)*sin(beta)*sin(alfa))), ((-cos(fi)*sin(alfa)) + (sin (fi)*sin(beta)*cos(alfa))), 0},
{ -sin(beta), cos(beta)*sin(alfa), cos(beta)*cos(alfa), 0},
{ pos_x, pos_y, pos_z, 1}
};
Cheers!!