AI move charge attack to a point to the other sid of player

Hi! I have an issue with my AI, in my thirdperson game. Im trying to make a enemy AI charge attack run past the player to the other side X -500 units away. My current code is a BTT_Task-> Ai move to, then I use charachter location and forward vector. Problem is that the AI always run to the location directly behind player, which means the player could turn around and prevent the attack, becaus the Ai always goes to the location behind the mesh.

Are there any clever ideas, should I use EQS or is there a better way? So AI should move from point A to B with the player in the middle and B directly behind the player on the other side. All help is appriciated :slight_smile:

Hey @Barbiezoldier! Welcome to the forums!

So there is certainly a way to do this! :slight_smile:
You need to get the player’s location, first.

Then you need to get the direction from your AI to your player. This lets it know what direction to go further past. We multiply that by the overshoot distance and add it to the player location and you’re done! You can even turn this into a function if you’d like, very easily! :slight_smile:

Hope this helps!

1 Like

Hi! I got it working! You are a lifesaver @Mind-Brain

Im a new dew and couldn’t figure this out… Thank you for the help, hope this helps someone else with the same problem.

1 Like

It seems that it didn`t work after all. I am not sure if my nodes are connected correctly. Here are my nodes in the picture. I tried adjusting the x values from -500 or +500 and nothing happens when I add it to multiply. When the AI does the attack it just stands in place and does nothing during the attack duration. I tried it directly as a function and in this image as the enemy AI blueprint. I call this function in a BTT task.

Well, if nothing is happening you need to figure out where the execution line is stopping! Try putting a print string before any code in the event, another in between “Goal Vector SET” and “AI MoveTo”, and a third and fourth on “Default, Success” and “OnFail”.

Then go test it. If the first one doesn’t go off, it’s not a problem with this code, it’s a problem further upstream, if the second goes off but a third doesn’t, it’s the AIMoveTo, and if all of them go off we need to re-evaluate. :slight_smile:

1 Like

@Mind-Brain Now I got it working, I had to do some tweaks I used print strings and everything was working. I changed the float to a vector and added the overshot distance 800 and 800 to X and Y. Also added an event dispatcher in the end of the code. I think the Float value was the problem, now it works in every angle if the enemy charges the player tested in many ways :slight_smile: Thank you!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.