How can AI Moves in a direction if he see me???

Hello
Just simple as that i need to now why my mannequin stays in his IDLE animation if im in hes see pawn here my simple noob code:

Thanks

try AIMoveTO instead of add movement input, of course that needs a navmesh

1 Like

I try it with both it dont work…i have green field also navmesh

what result are you getting?

animations wont matter yet, add a prints string on the pawn sensing and see if that ever fires

yes i can see the text

Chat gpt gives me this bp

To create a basic enemy AI in Unreal Engine that moves in a specific direction when the player enters its field of view, you can use the Blueprint visual scripting language. Here is a basic example of such a Blueprint:

  1. Create a new Blueprint for the enemy:

    • Right-click in the Content Browser in an empty area and select “Blueprint Class.”
    • Choose “Character” as the base class.
  2. Open the created Blueprint:

    • Open the created Blueprint and switch to the “Viewport” tab.
  3. Add a “Sphere Component” for the field of view:

    • Click on “Add Component” and select “Sphere” under “Basic Shapes.”
    • Adjust the size and placement of the sphere to represent the enemy’s field of view.
  4. Add an “AI Controller”:

    • Right-click in the Blueprint viewport and select “AI” → “AI Controller.”
    • Drag the created AI Controller into the “AI Controller Class” field in the Character’s Details panel.
  5. Open the “Event Tick” node:

    • Click on “Add Event” and select “Tick.”
  6. Add logic for enemy movement:

    • Connect the “Event Tick” to a “Get Player Character” node to obtain the player character.
    • Use a “Get Actor Location” node to get the positions of both the enemy and the player.
    • Calculate the vector between the player and the enemy, and use this vector to determine the direction of movement.
    • Add a “Set Actor Location” node to update the enemy’s position.

Here is a pseudo-code example of the Blueprint:

On Event Tick
    Get Player Character
    Get Actor Location (Player)
    Get Actor Location (Enemy)
    Calculate Direction (Vector between Player and Enemy)
    Set New Position (Enemy + Direction * Speed)

You can also use a “Line Trace” to ensure that the player is in the enemy’s field of view before triggering movement. Experiment with the exact values and add more logic to customize the behavior according to your requirements.

When I try it like this it works the ai moves but i dont want that he follows me just go straitght in one direction:

you can use the destination then, get its forward vector and multiple it by how far you want to go, can repeat on success if you want

sorry but can you make me blueprint picture of that so im sure that i do nothing wrong

use get actor forward vector you wont need a rotation, multiple that by a distance, say 500 for testing, add the result to get actor location and put the sum into destination

i cant add a “multiple” on “get actor forward”

you multiply the return value, ie the vector, just change the pin node to a float

hello my friend try now both ways but nothing work


what result are you getting?

is the pawn not being sensed?
is the branch failing?
is the AI not moving?
is the location wrong?

1 Like

hey auran THANKS A LOT for the try to help me!!!


this bp didn’t work because I had to multiply

The error that otherwise occurred was that it ran in the wrong direction

so you want the AI to move towards the player but only a set distance?

i think the aimoveto is trying to avoid the obstacle, does it work as intended without? if so you’d want a custom movement function

1 Like

everything works now but thank you very much for try to help me :slight_smile:
I posted the solution