UHFPS
  • 👋Welcome
  • 🎲Installation
    • URP - Project Setup
    • HDRP - Project Setup
    • Packages Setup
  • 🎮Getting Started
    • References
  • ⬆️Update Process
  • 📑Changelog
  • 📍Roadmap
  • ❔Support
  • 📚Guides
    • Managing Inputs
      • Adding Inputs to UI
      • Setting up Input System
    • State Machines
      • Adding Player States
      • Adding AI States
    • Save/Load Manager
      • Previous Scene Persistency
      • Encryption
    • Customizing UI
    • Interactions
    • Inventory
    • Player Items
    • Dynamic Objects
    • Motion Controller
      • External Motions
    • Hiding System
    • Narration System
    • Jumpscares
    • Puzzles
    • Objectives
    • Cutscenes
    • Options Manager
    • Game Manager
    • Localization
    • URP Specific
  • ⚙️Integrations
    • Emerald AI 3.0
    • AI Tree
    • Meet and Talk
Powered by GitBook
On this page
  • Adding new Motions
  • Creating new Motion Modules
  1. Guides

Motion Controller

PreviousDynamic ObjectsNextExternal Motions

Last updated 1 month ago

The motion controller is used to procedurally generate and combine multiple camera motions into one final motion, which is then applied to the camera. By blending multiple motions, it is possible to create realistic camera effects.

Motions are activated by changing the player's state to the specified state that the motions use. For example, motions in the Default state are always updated, motions in the Walk state are only updated if the player's state changes to the Walk state.

Adding new Motions

To add a new Motion State, simply click the Add State button and select the state. To add motion to a state, simply click the plus (+) button next to the Motion Data title and select the motion module.

Creating new Motion Modules

If you want to create new motion modules, you can choose between Simple and Spring motion module type. The difference between these two types is that the Spring type creates realistic motion similar to a human swaying. In some cases, you may need to create a simple motion, such as breathing, etc., so you can also use the Simple motion module type.

Here is a simple script that creates spring-like motion:

using UnityEngine;

namespace UHFPS.Runtime
{
    public class TestMotion : SpringMotionModule
    {
        public override string Name => "General/Test Motion";

        public override void MotionUpdate(float deltaTime)
        {
            Vector3 position = Vector3.zero;
            Vector3 rotation = Vector3.zero;

            SetTargetPosition(position); // set position motion
            SetTargetRotation(rotation); // set rotation motion
        }
    }
}

To create a simple motion, just derive it from the SimpleMotionModule. The newly created motions will be displayed when you click the plus button.

The same motion technique is also used in the player items, so you can create realistic motions when the player item is equipped.

📚