๐Ÿงพ
FPS Animation Framework
  • ๐Ÿ‘‹Welcome!
  • Workflow
    • ๐ŸฆพCharacter Rig
    • ๐Ÿ”ŒComponents
    • ๐Ÿ”ธProfiles and Layers
    • ๐Ÿ”—Linking
    • โž•Integration
    • โ–ถ๏ธPlaying Animations
    • ๐Ÿ’ปExtending the System
  • Demo Project
    • โœจResources
    • ๐ŸŽฎController
    • ๐Ÿ”ซWeapons and Items
    • โž•Attachment System
  • Fundamentals
    • ๐ŸฆพRig
    • โš™๏ธFramework Architecture
    • ๐Ÿ“‘Animator Profiles
    • ๐Ÿ“œAnimator Layer
    • ๐ŸŽฎInput System
    • ๐Ÿ”ถAnimator Layers
      • Weapon Layer General
      • Additive Layer
      • Ads Layer
      • Attach Hand Layer
      • Collision Layer
      • IK Layer
      • IK Motion Layer
      • Look Layer
      • Pose Offset Layer
      • Pose Sampler Layer
      • Sway Layer
      • View Layer
      • Blending Layer
      • Turn Layer
    • ๐Ÿ“šNew Animation Library
    • โš’๏ธTools
  • Recoil System
    • ๐Ÿ”ซRecoil Animation
    • ใ€ฝ๏ธRecoil Pattern
    • ๐Ÿ“นCamera Shake
  • Troubleshooting
    • โš ๏ธInitialization Warnings
    • โš ๏ธCan't Look Around
    • โš ๏ธWeapon Positioning
    • โš ๏ธWeapon is not moving
  • โš ๏ธAiming doesn't work
  • โš ๏ธTwisted feet when looking left/right
  • ๐ŸŒŒMisc
    • ๐Ÿ“œChangelog
      • 4.7.0 Update
Powered by GitBook
On this page
  • FPSController
  • FPSMovement
  1. Demo Project

Controller

In this section you will find out more about the demo scripts.

PreviousResourcesNextWeapons and Items

Last updated 9 months ago

The demo project heavily relies on these 3 components:

  • FPSController

  • FPSMovement

  • FPSItem/Weapon

FPSController

This class is responsible for updating user input for the animation system, changing weapons and calling callbacks on the currently equipped item.

The controller iteself does not implement reloading or firing logic, instead, such features are implemented in the FPSItem class. You can create custom entities derived directly from the FPSItem and override all the important functionality to fit your needs.

Now let's take a look at the FPSController's inspector:

Tip: make sure to add the component to the character root game object. This scripts manually rotates character for turn-in-place feature, so it is crucial that the whole player is rotated.

The component does not contain the data itself, instead, it uses an FPSControllerSettings asset. To create such an asset, right click and go to Create -> FPS Animator demo -> FPSControllerSettings:

Specfiy the Rig Asset, as we will use it to select bones in the Weapon section. Select the asset we created previously in the Character Rig section.

Unarmed Profile: this profile will be used when toggling the unarmed state.

Turn In Place Angle: if player exceeds this value, a turn will be performed.

Turn Curve: defines how the turn will be applied.

Turn Speed: the playback of the turning animation.

Time Scale: controls the real time scale.

Equip Delay: defines the delay time for the next weapon to be equipped.

Lean Angle: the max leaning angle in degrees.

Sensitivity: mouse input sensitivity scale.

WeaponBone: all weapons will be parented to this element. Just select the IK WeaponBone here.

Prefabs: defines all the weapon prefabs the system will spawn when the game starts.

As the demo project leverages Unity New Input System, you can find an Input Action asset in the Assets/Demo/Settings folder:

It already has all the important actions, and you can customize it according to your project needs.

Note 2024-04-26: the turn-in-place feature has been recently disabled in the demo project. A completely new system is coming soon.

FPSMovement

This script translates the character, controls its speed, pose and movement state:

Make sure to specify the Movement Settings - they define the speed of each state, smoothing and other locomotion settings:

Idle/Prone/Crouching/Walking/Sprinting are movement states, which only contain the velocity and velocity smoothing properties.

Crouch Ratio will be multiplied by the player's standing height. For example, if set to 0.5 the player's height will be decreased twice when crouching.

Air Friction defines how controllable our player is when in the air. 1 means 100% controlled, and 0 means no movement input is applied.

Air Velocity defines the movement speed multiplier when in air.

Max Fall Velocity defines the max vertical velocity.

Slide Curve is a delta curve, applied when sliding.

Slide Direction Smoothing controls the rotation smoothing when sliding.

Slide Speed controls the general velocity when sliding.

๐ŸŽฎ
FPSController inspector.
Controller settings.
PlayerControls.
Movement component.
Movement settings.