Skip to content

1. Initial Setup

J1blCblu edited this page Sep 15, 2022 · 25 revisions

This page is up to date to the latest version.
Previous versions may differ, but the core concept is still the same.
Modules are just used to encapsulate the logic.

Initial Character setup

  1. Add the LockOnTargetComponent to your character.

image

  1. Set the DefaultTargetHandler to the TargetHandlerImplementation. It's basically used to find a Target.

image

  1. Update the player's input. Input Overview.
  • Capturing and releasing the Target:

image

  • Switching the Target with the axis input:

image

Note that the raw input is processed in the component, you don't need to setup any EnhancedInput features.
Perhaps in future updates the input will be processed via the EnhancedInput.

Camera.

  1. Make sure to set the UsePawnControlRotation to true in the Camera or the SpringArmComponent.

image

  1. Add the ControlRotationModule to the DefaultModules.

image

  1. Expand the ControlRotationModule and add the LazyInterpolationModule.

image

  1. (Optional) If you want to move the Target from the center of the screen.
  • Change the OffsetRotation pitch value in the ControlRotationModule->LazyInterpolationMode->BaseConfig to -10.f.

image

  • Change the ViewRotationOffset in the DefaultTargetHandler->DefaultSolver to the opposite value.

image

Widget

  1. Add the WidgetModule to the DefaultModules.

image

Initial Target setup

  1. Add the TargetingHelperComponent to the Target.

image

  1. Select a desired mesh in the MeshName. Socket location will be calculated from that mesh.

image

  1. Select desired sockets in the Sockets. Sockets are used for finding and tracking.

image

Strafe Movement

There are many ways to achieve this behavior. The easiest one will be demonstrated below. For a multiplayer game you may want to extend the UCharacterMovementComponent, all the necessary information is provided by the LockOnTargetComponent. This is not done in this plugin, cause otherwise the plugin would be very complicated and impose restrictions (inheritence from the custom Character).

  1. Add the OnTargetLocked/Unlocked events from the LockOnTargetComponent:

image

  1. Disable the bOrientRotationToMovement in the CharacterMovementComponent if used.

image

  1. Add the OwnerRotationModule to the DefaultModules and set the RotationMode to the InterpolationMode. Set the RotationAxes to the Yaw.

image

Clone this wiki locally