I’m trying to replicate the auto targeting system of a game (Parasite Eve:3rd Birthday).
-Pressing lock on key will automatically lock on to the closest enemy in characters forward direction and enter lock on state.
During Lock On State:
-Pressing down key locks on to closest enemy regardless of facing direction
-Pressing lock on key +left/right will target the next enemy of corresponding direction based on players facing direction.
I’m looking for coding examples/guides and how this might be accomplished.
Trigger method:
-Stores all enemies in a list and their distance inside the trigger. Remove when they are no longer inside the trigger.
-Compares players position and rotation(?) to execute lock on functions above.
Raycast method:
-Cast ray based on player input to quickly scan and snap to the first target found.
-Not sure how targeting closest enemy would work
-Which raycast to use for good accuracy? Spheres/Planes?