AI Moving on one Axis

Hi,
I’m still trying to make a Pong game to learn the basics in game programming and I have a strange Behaviour from my AI.
Basically I Want my AI to follow the ball on the “Y” Axis to catch the ball (I’ll managed to the IA can missed it later).


The movement is not perfect but it’s working exept it’s moving on the X axis a little too.

It’s even doing it if I writte a fixed value in the X axis.

Maybe I’m not doing it the right way I don’t know, it’s maybe easy but now I don’t see it.

Thank you

That’s because what you’re doing is pathfinding.
Even if the destination is the exact same on the X axis, it may need to move a bit to avoid things.

What do you need the exact X coordinate for if you don’t mind sharing? Maybe there’s a better solution for your specific application.

Hi,

Ok I think I understand why its moving now, I didn’t know it was pathfinding what I did
thanks for your Reply,

the exact X coordonate is 180.

Hi,

I figured it out, it’s not a smooth movement but now it’s moving only on the “Y” Axis.

As my Pawn is just a collision Box and a static Mesh I’m not sure if I can add some force or velocity to the movement…

Thank you