Cast from Player position towards Left stick direction relative to camera

Hey guys, im having some trouble here

Anyone knows what would be the correct way if I want to do a Batman Arkham asylum type of targeting?

Basically, if the stick isnt held, I soft lock to the closest Ennemy which i can already do, but what i can’t seem to do is to aim towards and target them while im attacking to switch targets.

Anyone has an idea how this could be done?

make two variables, ClosestDirEnemy, and MinDirEnemyDiff (set that to 1 before the loop)
GetAllActors of enemies within a certian radius, then loop through them. In the loop, set MinDirEnemyDiff to the dot product of the LookAt between the enemy’s position and the unit vector of the direction you are pointing the thumbstick in world space, But only if it is less than the current MinDirEnemyDiff already set. If you set the MinDirEnemyDiff then also set ClosestDirEnemy to the current enemy in the loop.

When the loop is completed the ClosestDirEnemy should be the enemy that stands in the spot closest to the direction your thumbstick is pointing in worldspace.

i havent tested this idea - let me known if it works.

Hey im gonna try this out right now, im guessing Thumbstick direction in world space would be taking the X and Y axis input values rotated by the “Get control rotation” like this?

Woops disregard the x5000

I’m not sure but it’s worth a try (I haven’t actually tried my idea out myself yet - it’s just the first thing I would try if I was doing what you are doing). Also turn on the Debug Color options in your line trace so you can see where it’s trying to go.