Line trace by channel with ai

Hello, I am trying to make the ai destroy my actor when he is near me with line trace by channel. I can use this function just fine as a player, but I can’t seem to make it work with bots. If I use get actor location, the trace starts where the bot was spawned. Is there a way I could use get world location with the ai? Maybe if I create a camera and link the camera component to my blueprint? Here is what I have :

Also, it seems that the ai aims at my feet, why is that so?

Thanks

The “aim at your feet” has to do with that forward vector. You could try using the Z coordinate of the “Start” vector in the “End” vector as well, to ensure they’re the same.

The get actor location node does work and will return the current location…How often are you calling ‘event receive execute’? If you aren’t doing this already, try executing this using an ‘on tick’ event to make sure the location is constantly being updated.

Wouldn’t that waste power if there is another way to get it’s location? And as for the Z coordinate, if it works with me, shouldn’t it work with the ai?

I don’t think the question is if it “should” work but if it does work :P.

Sure, firing the event on tick will certainly waste resources if it doesn’t need to be updated more than you need it to.

I’m not entirely sure what it is that you are trying to achieve here though, I assumed you wanted the AI to be constantly performing the trace, always trying to hit your player? I asked how often you are firing the event because I suspect you are only calling it once when your AI is spawned.

You will need to provide more details of what it is you are trying to do, how often you are calling the event, whether or not the trace rotation is being updated and in what blueprint this all belongs to (i.e. character, behaviour tree service, behaviour tree task…etc) But I can assure you that get actor location works with AI.

For the Z location of the trace, you could simply break the vector and add some value to the Z before passing it in to the start and end inputs of the trace node.