[Question] Auto AIMING function?

HI!

its basicaly an auto aim for a platformer or 3d game i guess… its it possible ???

You could just go with a line trace.

When your trace hits something you try and cast it to one of the things you can hit or you read a label on the things you put in the level and read those.
Then you need to adjust the rotator so that it lerps to a new rotator that looks at the target.

Sure it’s possible. First you need to find all enemies. There’s several ways to do that. If you want to limit this autoaim functionality to a specific maximum distance, you could simple use an additional collider on your player. Once an enemy overlaps this collider, you save a reference of it in an internal list which you use to determine which enemy is closest (Remember to remove the enemy if he leaves the collider). If you always want to find all enemies regardless of their distance, you could simply derive them of a base type or create a common interface and do a “get all actors by class” or “get all actors with interface” and process this list.

Next you would need to find the distance to the closest enemy. This can be done by simply taking your and the enemy’s location, subtracting them from each other and getting the vector length of the result. You do this for all enemies and compare which length is the smallest. This is the enemy closest to you. If you want to be thorough you can do an additional linetrace between you and the closest enemy to check whether something is blocking your line of sight. If so, repeat the process above without the enemy which is blocked until you find a proper target.

Also for finding the rotation, simply take a vector node and create the “find look at rotation” node with your character being the start and the enemy being the end node.

Basically you could have all enemy’s in a list of somesort then sort the list with some math to check which enemy’s position is closer to the player then take that information from that check and put it into the players aimer.

If you want to have a bit of distance you could give the player a trigger box that adds the enemy on collision to a list then does everything i just mention before.

Use your GET.

Get all actor or arrays might be a trouble.

Can it be done with a line trace? How will a line trace will get to hit the chicken after I kill the monkey, how is it possible that a single line trace can read the enemy that is higher and change my rotation to target it?

Getting all the actors shouldn’t be hard, just gather them and use pointers for later access. When you need to cycle to the next, just loop the array and check which one is closer.
Alternatively, you could add a volume with the range of the weapon, and when you need to change/aim, just pick the enemies within such volume.

Can my line trace(blue) trace that the chickenBP collision box is under its feet so it feed my character aim rotation?

That’s what I need to do. Anyone know a way?