Hi!
I’m building a third person shooter and I’m trying to make the character shoot at the enemy only when aiming at it. Up to now, when in aiming mode, the character’s aim offset is used to point where the camera is pointing, and an IsAiming boolean is used to prevent the player from shooting if not aiming, so bullets don’t get fired everywhere if the weapon is not pointing “downrange”.
My next step is to make the player only fire at enemies (I"m trying an auto fire system for mobile controls testing). I would like to trace from the camera and check if the first hit object is an enemy. I’m currently using an “IsEnemy” boolean on BeginPlay to differentiate characters that are not controlled, but I’m open to suggestions. I know about how to get the tag of object under cursor, but can’t seem to find a way of doing it properly with the camera. The end goal is to trace while the player is aiming (from the active camera, also have a sniper camera) and if the actor that I point to is an enemy, call the Fire function.
It would be great if the solution was actually a line trace, because I could set the limit to be a variable “weapon range”.
I’m pretty sure the answer is under my nose!
Thanks everyone.