# FlyingAI

Hi I have tried to make a space game but I am struggling with the hostile alien AI. It is really simple but It can not navigate around objects to chase the player. I have tried to do it by line trace but it is not very clever or accurate.

Here’s what I have so far

How did you put the navigation mesh in space?

Try this…it’s my function to fallow…

“IA Move To” It works badly, so I had to make some adjustments to be able to use it… That’s why you might see some weird stuff… But at least for me it works…

Hi my code works and I don’t need help in moving my character but it has no pathfinding ability. I need a way of the AI to navigate around objects.

to answer your question How did you put the navigation mesh in space? I am making a space game so I cant use it so I am needing a way for the Ai to go around objects.

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.

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={//16
{1 , 0, 0, 0},
{0, cos(beta) , sin(beta), 0},
{0, -sin(beta) , cos(beta), 0},
{0, 0, 0, 1} };

float MRoty={//16
{cos(fi), 0, -sin(fi), 0},
{ 0, 1, 0 , 0},
{sin (fi) , 0 , cos(fi), 0},
{0, 0, 0, 1} };

float MRotz={//16
{cos(alfa) , sin(alfa), 0, 0},
{-sin(alfa) , cos(alfa), 0, 0},
{0, 0 , 1, 0},
{0, 0, 0, 1}};

## float MRot={ {(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={
{(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={
{(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!!