Manuals of ComponentCameraSystem
  • Introduction
  • Basic Uses
    • General Workflow
    • Working with Sequencer
    • Third Person Camera
    • Lock-On Camera
    • Camera Shake
    • Camera Postprocessing
    • Camera Lens Effect
    • Camera Dither Fade
    • Photo Mode (Experimental)
    • Other Features
    • FAQ
  • Advanced Uses
    • Change Component Properties at Runtime
    • Customizing Camera Components
      • Customizing ECameraComponentFollow, ECameraComponentAim and ECameraExtensionBase
      • Customizing Existing Components: ControlAim as An Example
      • Customizing ECameraGroupActorComponent
      • Customizing ECameraHUD
      • Customizing EPlayerCameraManager
    • Camera Dampers
    • Animating Camera
    • Mixing Camera
    • Sequenced Camera
    • Keyframing Camera
    • ArchViz Camera
    • Integrating with Montage
    • Integrating with Gameplay Ability System (GAS)
  • Showcases
    • Boss Battle Camera
    • Group Aim Camera
    • Orbit Camera
    • Rail Camera
    • Crane Camera
    • Third Person Framing Camera
    • First Person Shooter Camera
    • Pseudo First Person Shooter Camera
    • Static Camera
    • Only Follow Camera
    • Only Aim Camera
  • Camera Components
    • Follow Components
      • ScreenFollow
      • SimpleFollow
      • HardLockFollow
      • OrbitFollow
      • RailFollow
      • CraneFollow
    • Aim Components
      • TargetingAim
      • HardLockAim
      • ControlAim
    • Extension Components
      • ResolveOcclusionExtension
      • MixingCameraExtension
      • ConfinerExtension
      • ResolveGroupActorExtension
      • AnimatedCameraExtension
      • KeyframeExtension
      • ConstrainPitchExtension
      • ModifyAimPointExtension
      • VelocityBasedRollingExtension
    • Miscellaneous
      • Photo Camera
      • Animated Camera
      • Keyframed Camera
      • ArchViz Camera
      • ArchViz CineCamera
      • ArchViz Camera Component
      • ArchViz CineCamera Component
      • Sequenced Camera Actor
      • Group Actor Component
      • CameraModifier_CameraShake
      • PCMGNeuralNetwork
      • ECamera Shake Source Actor
  • Blueprint Nodes List
    • ECameraBase
    • ECameraSettingsComponent
    • EPlayerCameraManager
    • ECameraLibrary
    • ECameraGroupActorComponent
    • RailFollow
    • ScreenFollow
    • ControlAim
    • MixingCameraExtension
    • VelocityBasedRollingExtension
  • Code Framework
    • Code Framework
  • Changelog
    • Changelog
      • V0.1.x
      • V0.2.x
Powered by GitBook
On this page
  1. Advanced Uses
  2. Customizing Camera Components

Customizing Existing Components: ControlAim as An Example

PreviousCustomizing ECameraComponentFollow, ECameraComponentAim and ECameraExtensionBaseNextCustomizing ECameraGroupActorComponent

Last updated 10 months ago

Sometimes you want to slightly modify existing components rather than implementing a new component from scratch. ComponentCameraSystem offers an extensible solution for you to override existing components, but in a limited way.

Concretely, you can override an existing component, say ScreenFollow, to incrementally add functionality to it. But you cannot manipulate the implementation details of the component. You can only complement additional logic after the component has been executed. If you are familiar with programming, this is equivalent to first calling the parent method and then doing anything else.

Let us take ControlAim as an example. This component receives player input to control camera orientation. I want to implement an "auto-rotating" function, where camera will automatically rotate around the follow target if no input is received for a specific period of time.

  1. Right click on Content Browser -> select "Blueprint Class" -> Search for "ControlAim" -> click "Select".

  2. Rename it as whatever you want. Here I name it MyControlAim. Open the blueprint class and you can see the "Functions" section on the left side of the blueprint window. There are several implementable functions in this section. For this component, you should implement the OnBecomeViewTarget and UpdateComponent functions, while other functions, if meet your needs, can also be implemented.

  3. Define some variables. FollowTarget is used to detect whether the follow target is moving. WaitingTime is the duration to wait for enabling auto-rotation. RotateSpeed is the self-rotation speed. CachedFollowTargetLocation is follow target's location at previous frame. ElapsedWaitTime is the elapsed time since no input is given.

  4. In the OnBecomeViewTarget function, you should set FollowTarget.

  5. In the UpdateComponent function, first call the parent method, then call your custom DoSomething function.

  6. The DoSomething function is the place where you implement self-rotation. Below is a reference implementation but feel free to make your own. The workflow is simple: first check whether the follow target is moving or input rotation is received (via the GetMouseDeltaX and GetMouseDeltaY nodes). If true, reset ElapsedWaitTime, otherwise add increment to it. Next check if ElapsedWaitTime has exceeded WaitingTime, and if true, add rotation to camera. Last, update CachedFollowTargetLocation. It is particularly noteworthy when using FollowTarget I did not check its validity. But technically you should do this whenever you use it.

  7. In the camera actor (of class ECameraBase or sub-class of ECameraBase), specify MyControlAim to the "Aim Component" property and set "Follow Component" with ScreenFollow. Go to the blueprint where you want to call this camera. Invoke the CallCamera node and specify "Camera Class" and "Follow Target". You can also specify blending parameters if you like.

  8. Run the game, wait for WaitTime seconds, and you will see camera is smoothly rotating around the follow target. When character moves or camera input is given, self-rotation will stop and you have to wait another WaitTime to enable it.