Skip to content

1. Initial Setup

J1blCblu edited this page Apr 20, 2022 · 25 revisions

Initial Character setup

  1. Add the LockOnTargetComponent to your character.

image

  1. Set the DefaultTargetHandler to the TargetHandlerImplementation.

image

  1. Set the LazyInterpolationMode in the ControlRotationModeConfig.

image

3.1 (Optional) If you want to move the focus point from the center of the screen.

  • Change the OffsetRotation in the LazyInterpolationMode->BaseConfig.

image

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

image

  1. Update the Character's input.
  • 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.

  1. (Optional) Strafe movement.

Add the OnTargetLocked/Unlocked events from the LockOnTargetComponent:

image

Disable bOrientRotationToMovement if used.

image

There are two possible ways next:

  • When using the LazyInterpolationMode, the rotation offset in any RotationMode or the Character is looking in the wrong way:

    • Fill the OwnerRotationModeConfig with the InterpolationMode or RotationModeBase.
      image
    • Choose the proper axes in the BaseConfig.
      image
  • Otherwise:

    • Clear the OwnerRotationModeConfig if it is set.
      image
    • Set the bUseControllerRotationYaw in the APawn subclass or the bUseControllerDesiredRotation in the UCharacterMovementComponent.
      image

Initial Target setup

  1. Add the TargetingHelperComponent to the Target.

image

  1. Change the None socket to the desired. None socket is only used for the RootComponent. (Note that the Sockets aren't validated.)
  2. Change the MeshName to the desired (if there're multiple Meshes, otherwise the first MeshComponent will be used).

image

Full Setup

Clone this wiki locally