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 specifies a given point in three-dimensional space by using a distance and two angles as its three coordinates. These are
(See graphic regarding the "physics convention".)
Once the radius is fixed, the three coordinates (r, θ, φ), known as a 3-tuple, provide a coordinate system on a sphere, typically called the spherical polar coordinates.
The plane passing through the origin and perpendicular to the polar axis (where the polar angle is a right a...
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!!