Paper2D Enemy Ai Problem?

I don’t understand why doesn’t it go towards the x axis help ???

I’m not sure what you’re asking, but I think you’re trying to get your character to move along the x-axis.

The blueprint you’ve shown is going to move your character from its current location one unit away in any direction over and over again. It will not move in a straight line, it’ll bounce forward and back, up and down, randomly, but only very small movements each time and basically evenly in every direction - and every time you reset the Y and Z axes to 0, so only movement in one axis is preserved. The second screenshot looks like that might be what’s happening.

The “GetRandomPointInNavigableRadius” creates a sphere at the point you supply with a radius you supply; it returns a random point somewhere within that sphere that is navigable - so the result is a point up to the length of the radius away from the center in any direction.

You’ve given it the X coordinate only, so the sphere is created at (X, 0, 0) every time; and the radius you’ve supplied is 1 - so it’s very small. You then move the character to that point, delay, and then call back recursively.

If the sphere is not directly along the X axis (highly likely), and not at the extreme edge (also highly likely), the movement along the X axis is going to be ± < 1 each time. And since it’s random, it could be forward or backward, and will basically cancel itself out with enough iterations.

Let’s say you start at X = 5.0. The first iteration your sphere is going to be at (5, 0, 0), the FURTHEST AWAY your next sphere can be is at (4,0,0) or (6, 0, 0); if the random point is straight up you’d be going to (5, 0, 1) and the next iteration would be at (5, 0, 0) again. Even if you get to (4, 0, 0), the next iteration the furthest away can be (3, 0, 0) or (5, 0, 0); and if it’s 5 you’re back where you started.

If you have a direction you want the character to move, get the current location and increment or decrement X by one (or some other value) - but you have to keep adding OR subtracting - that will move the character in a straight line along X. If you randomly add or subtract, you’re more or less going to stay in one area as long as the distribution is even.

i want my character to move forward and backwards but on the x axis not to pick more locations

Then don’t use GetRandomPointInNavigableRadius.

You have to know if the character is going in the positive X or negative X direction, and then add a negative or positive value.