Announcement

Collapse
No announcement yet.

Targeting in third-person/first-person SP game - advice?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Targeting in third-person/first-person SP game - advice?

    Does anyone have any working examples of a "robust" system for targeting and target highlighting for a single-player game, in the Skyrim/Fallout style? I.e., combination first & third person perspective with a targeting reticle, and the current "target" is the closest object under the reticle that meets certain requirements (like being a character or "activator")?

    I have a system working right now that works, but it seems a little clunky and possibly inflexible. It consists of the following:

    1. A BP component called "Activator" that contains a "Target Changed" event, which passes a "New Target" Actor as an argument. When "Target Changed" is called, it checks to see if "New Target" is equal to its owning Actor. If True, it turns on object highlighting on all Static and Skeletal Meshes in the Actor. If False, it turns highlighting off. (I use Custom Depth-Stencil postprocessing for this.)

    2. A LineTraceForObjects in my Character BP that populates a "Current Target" Actor variable on the Character with the hit result of the line trace. If the hit result Actor is different from Current Target, it calls "Target Changed" on the Activator component on both the Current Target and the "new" target, with the new target as the argument. Then it updates Current target with the new target.

    So this works, but it is a little clunky because the logic to "do something" to the target is on the Character BP. Wouldn't it be more "clean" to have the Character just keep track of its current target and have some event sent out when it changes, and for objects to "listen" for the event to decide what to do with it (if anything)? My current implementation needs to call events directly on the target Actors (or more specifically, a custom component on the Actors), which seems like bad design.

    Does anyone have *working* examples that are better designed?
Working...
X