Line trace acting oddly?

I’m doing a line trace by channel and I’ve noticed two odd things -

one, the line goes from the target to the start point, not the other way around.

second, using the visibility channel doesn’t work, I have to use the camera channel.

Can anyone shed any light on these things?

Hey (:

would you mind showing me your Blueprint Setup including the Line Trace and the channel settings of the Actor you want to trace?

I’m having the same issue. In BTS_BotDetectPlayer I am doing a Single Line Trace from the Bot to the Player - however I have to reverse the logic to get the expected state: StartNode=Player and EndNode=Bot & the result is the Bot to cast a line that ends at the player.

I’ve verified this by printing to the screen (to double check the world positions) and spawning a projectile at the hit/reading the hit . Definitely working backwards but I can’t understand why. For my BP_mainplayer I have another SLT that works as it should so that I can shoot bots. Not sure why one works correctly and the other I have to setup back-to-front

Hi Guys

This is the way I set mine up for 1st Person. Compare

Yep that’s similar to my third person setup (which works for firing etc) but for the AI Blueprint Service it needs it backwards. So strange!

What is you code for bot?

I lie, that is setup for my turret.

This is my bot.

42202-capture.jpg

Why is player location plugged in to start?

Should in not be the other way around?

Exactly my point. If you see my screenshot (in-game) the only way I can get the Bot to see my player and have the raycast end at the player (as proven by the spawning of the explosion) - is IF I set them up the wrong way around. Makes no sense.

Update: So I came here looking for why it seems to be going back-to-front and it found the OP of this question saying his seems to be back to front as well. Maybe there’s a bug in UE4 for certain situations?

Mmmmmm

There are so many things there that make no sense.

If I got it right, you are spawning emitter at enemy location, but it is spawning at player location?

You are spawning emitter before you check if it hits character.?

Just to confirm, as there are a lot of lines running.

Yep correct on all fronts. The spawn was just to double check it really did end at the player (despite the End:being set at the bot). The spawn location is the hitactor output

What happens if you set up the hit, the same way for player character.

I.E. forward vector, as same as player.

It must be the way the line trace works.

Get find loop up rotation and run it like that.

Example how I do it, this has movement, but you could take that out.


Also, why would you line trace, if you are just referencing the player anyhow?

This service runs every tick and is the check to see if the enemy/bot has detected the player. The line trace gets done once the player is within a specific radius (to check if they’re visible / obscured). At the moment I have both parts of the branch going to the raycast (since I want him to do it all the until this issue is fixed).

This setup works almost as intended (the bots navigate the environment in a Patrol state until the radius + raycast logic allow them to see the player). The bot then switches to a Search state and will continue coming after the player until it gets close enough to trigger the Attack state. After that, distance between bot/player will allow the bot to go back to Search.

I had the forward vector logic before and had the same issue with it running backwards. Will set it again and do some screengrabs

Are you using Pawn Sensing?

Might be an issue with the “casting”, not the line trace.

I will see if I can get a second eye on this.

The cast is not the wrong way but just hitting something as soon as it spawns :wink:

The green line means something has been hit and that’s the the length the full trace would’ve had. To fix this make a new array for the “Actors to Ignore” and add the reference from your cast and you should be all good.

Cheers!