Camera Mode Scripts

Camera Mode Scripts are a powerful feature of the Advanced Third Person Camera plugin, enabling you to go beyond the plugin's built-in settings and inject custom logic into your camera modes. This opens up a world of possibilities for tailoring camera behavior to your specific gameplay needs, creating unique and dynamic camera experiences.

What are Camera Mode Scripts?

Camera Mode Scripts are essentially custom classes that are created and executed in conjunction with specific camera modes. They allow you to run your own code whenever a camera mode is activated, deactivated, or even on every frame while the mode is active. You can create Camera Mode Scripts using either Blueprint visual scripting or C++ code, depending on your preference and project requirements.

Creating Camera Mode Scripts

  1. In the Content Browser, right-click and choose "Blueprint Class."

  2. Select ATPCCameraModeScript as the parent class.

Key Functions and Events

Camera Mode Scripts provide several key functions and events that you can override to implement your custom logic:

  • OnEnterCameraMode(UATPCCameraComponent* Camera): This function is called when the associated camera mode becomes active. It's an ideal place to perform initialization tasks, such as:

    • Modifying character movement speed or turning radius.

    • Enabling or disabling specific player input actions.

    • Triggering animations or particle effects.

    • Setting up variables or timers for custom behavior.

  • OnExitCameraMode(): This function is called when the associated camera mode is deactivated. Use it for cleanup tasks, like:

    • Restoring previous character movement settings.

    • Re-enabling disabled player input actions.

    • Stopping animations or particle effects.

    • Clearing timers or resetting variables.

  • Tick(float DeltaSeconds): This function is called every frame while the associated camera mode is active. It allows you to implement continuous logic, such as:

    • Smoothly interpolating values over time.

    • Updating custom camera offsets or rotations based on gameplay conditions.

    • Monitoring player input or character state to trigger specific actions.

Enabling Ticking:

  • Blueprint: The Tick event is available by default in Blueprint Camera Mode Scripts.

  • C++: To enable ticking, set the bEnableTick member variable to true in your script's constructor.

Assigning Scripts to Camera Modes

Once you've created your Camera Mode Scripts, you need to assign them to the specific camera modes where you want them to be executed.

  1. Open the Camera Mode Data Asset: In the Content Browser, open the UATPCCameraModeDataAsset that defines the desired camera mode.

  2. Add the Script: In the Details panel, locate the "Camera Mode Scripts" array. Add your Camera Mode Script Blueprint or C++ class to this array.

  3. Multiple Scripts: You can add multiple Camera Mode Scripts to a single camera mode. They will be executed in the order they are listed in the array.

Practical Examples and Use Cases

Camera Mode Scripts provide a versatile tool for enhancing your camera systems. Here are some practical examples of how they can be used:

  • Change Movement Speed: Create a script that modifies the character's movement speed or turning radius when entering a specific camera mode (e.g., slowing down when aiming).

  • Trigger Animations: Trigger animations based on camera mode changes. For example, play a "draw weapon" animation when entering an aiming mode or a "get into vehicle" animation when entering a driving mode.

  • Enable/Disable Player Actions: Restrict or enable specific player actions based on the active camera mode. For instance, you might disable jumping or sprinting while aiming.

  • Custom Camera Offsets: Implement dynamic camera offsets that adjust based on gameplay conditions. This could be used to create a leaning effect when the character takes cover or a bobbing effect when running.

  • Cinematic Sequences: Trigger and control cinematic camera sequences based on camera mode changes or player interactions.

Last updated