AI Trace to Attack

Hi, I am trying to get an AI to attack if a trace hits the main character. The only issue I am having is that once the trace hits the character the AI does not stop attacking (Sorry if this is too vague I can try to explain further…).

Here’s a picture of my AI’s Blueprint: Screenshot - 4a0ed6b2b1d73b93b5a68e6cf94d426d - Gyazo

And in the animation BP it plays a melee attack montage when the boolean attacking is true.

Are the Print Strings being called as expected?

The true is printed when the trace hits the main character but it stays true never printing the false even if the trace is not hitting.
I am looking for the AI to attack when the trace is hitting the main character and stop when it is not.

Hi

As per above, or you may just use Pawn Sensing. Depending on how far you want it to detect, but because your X is only small, you are not looking for far detection.

You need to check the ReturnValue from LineTraceForObjects. You have an == test for HitActor, but the OutHit struct is only valid when LineTraceForObjects returns true. So your condition should be: ReturnValue AND HitActor==MainCharacter. The Set NewVar node isn’t needed.

One hint: You don’t need to put the self character into the ignored array if you check ignore self

tyvm kamrann this works perfectly