Support Forum

I want to move my AI by myself

I want to move my AI by myself. All that I need - a position, where to move, after I call “seeker.StartPath(GetFeetPosition(), destination)”, with avoidance of other AIs. Is it available?
“steeringTarget” is not suitable, “simulatedPosition” gives strange result.

Hi

Have you seen this tutorial: https://arongranberg.com/astar/docs/custom_movement_script.html

If you are using one of the built-in movement scripts you might also be interested in: https://arongranberg.com/astar/docs/iastarai.html#MovementUpdate

Ok, but these links about moving along path. But I mean a point for every frame movement, with calculated avoidance included, if AI has rvocontroller and the scene - rvosimulator.

Yes, that’s what those links provide you. If they are not suitable then you’ll have to explain a bit more about what exactly you want to achieve.

Please, make a sample scene, using humanoid character model, not cubes or mine bot, which has no face direction. I was not able to make my AIs move in normal behaviour using aipath or richai - Ais must always move in face direction, but depends on rotation speed, they can move sideways, backwards and so on. Why AI not able to rotate in place??? It rotated only when moves.

I mean, AI always must move along forward direction - tr.TransformDirection(Vector3.forward), only rotation and velocity must be changed. Current movement in AIPath and RichAI is wrong.

Hi

There’s a setting on the AIs called “slowWhenNotFacingTarget” which might be what you want?

Yes, “slowWhenNotFacingTarget” makes the AI face the direction of movement, but there are many different types of enemies in my project, and this “slowWhenNotFacingTarget” movement cannot be applied to any of them. It does not stop, when the destination in opposite direction, and always moves.
And I too dumb to fix this, it requires another direction variable to rotate the transform, when it stops.

For “slowWhenNotFacingTarget” = false, I removed controller.Move, and added these very incorrect lines in AIBase:
Vector3 dir = slowWhenNotFacingTarget ? (nextPosition - currentPosition) : (tr.TransformDirection(Vector3.forward) * maxSpeed * Time.deltaTime);
controller.Move(dir + accumulatedMovementDelta);
Now it looks visually ok for this type of movement, always faced in movement dir, and suitable for fast and heavy-weighted horse-like AIs.

How to make AI stop and rotate, when the destination in opposite direction? How to correct the code, when “slowWhenNotFacingTarget” = false?