Target selection leaking through and targets characters behind actual target

Okay so first off I am extremely new to this, I started messing around with Unreal ~3days ago. I watched a Youtube tutorial to just get this Ability system going just to get some basics. And try to learn something, and I love the idea of the system but there’s this issue where the Crosshair-Target leaks through and hits the target behind my actual target

-But I believe the issue should lie in this first one since this should be the one that “looks” for the target to highlight

I want it to simply always target the one that’s in the middle of my screen, so my crosshair dictates the target

This is how it’s supposed to be, I look at him and I target him

This is the issue, where it sometimes targets/highlights the player behind who I’m actually pointing at

Here’s some more BluePrints

And this one is in my ThirdPersonCharacter Blueprint

The examples above are all just ThirdPersonCharacters I dragged out

I was thinking that maybe the nodes after my “FollowCamera” in the first picture are the culprits? If I can somehow more accurately pinpoint that to the center of the screen?

Thanks a lot in advance!

From the first glance, you are using normalized target direction vector and forward player vector to find your selection. It looks like you are comparing dot products of normalized vectors. That will give you a target closest to the center of the screen, but not closest by distance. I think you will have to calculate and store distance on each actor you are testing and have some logic which will prioritize, which one to choose.

But this logic seems a bit weird to me and more complicated than needed. I would rather use a trace for objects. That way I would hit something visible of specific class/object type under the cursor.

1 Like