I wanted to try this out to see if I could make something useful for you so here you go
This is a pretty simple script and I’m sure it could be improved a lot but I wanted to give it a shot. I have a boolean flag determining whether the player is targeting something or not (I know a lot of people are against bool flags, but I didn’t know how else to approach this). If the player IS targeting something, it toggles off the flag. If the player is not targeting something it runs the function that drives the targeting system. To start, it grabs all actors in the scene and throws them into an array. For simplicity’s sake, I grabbed the actor at index 0 (in this case it’s a sphere I have in the game). I’m sure this could be elaborated on in future iterations such as cycling through targets (changing the index being called from the array) or making a bounding box that only selects nearby targets. Then, we check if there is anything to target (checking if the array has one or more indices). If it doesn’t, nothing happens if it does, you can target what’s at the index you choose. Then there’s math, but it’s super simple. I think that find look rotation is probably easier than the way that Chumble chose to explain. Literally all it needs are the locations of the player and the target and voila! it makes a rotator for you! For simplicity’s sake, I only have the player rotating around the z axis. The flag is set for targeting and the rotation on the character is set relative to its current rotation. Looking out on the main character graph again, every event tick the function is called if the player currently has the istargeting bool flagged. I’m not sure if this is the most efficient way to call this repeatedly, but hey I gave it a shot, right? I only started UE4 last week so cut me some slack if something is messy.