Base Character
Introduction
Base character class
Dependencies
The USKCharacter
relies on other components of this plugin to work:
- Logger: Used to log useful information to help you debug any issues you might experience
- Audio: Used to play sound effects either 2D or at a specified location
Camera Clipping
Sometimes parts of the character mesh or weapon might clip when close to the camera (especially while aiming). This can be fixed by changing Set Near Clip Plane
to 0.1
in your project settings
Components
The USKCharacter
uses the following components:
Name | Description | Type |
---|---|---|
CameraComponent | The camera used by the character | UCameraComponent* |
SpringArmComponent | The spring arm component responsible for controlling the distance of the camera | USpringArmComponent* |
CrouchTimeline | The timeline component used for smooth crouching | UTimelineComponent* |
ProneTimeline | The timeline component used for smooth proning | UTimelineComponent* |
AimTimeline | The timeline component used for aiming | UTimelineComponent* |
LookAtCenterTimeline | The timeline component used to look at the center of the screen | UTimelineComponent* |
API Reference
Properties
Property | Description | Type | Default Value |
---|---|---|---|
InputMappingContext | The input mapping context used by the character | UInputMappingContext* | nullptr |
MoveAction | The move input action | UInputAction* | nullptr |
LookAroundAction | The camera rotation input action | UInputAction* | nullptr |
JumpAction | The jump input action | UInputAction* | nullptr |
SprintAction | The sprint input action | UInputAction* | nullptr |
FireWeaponAction | The fire weapon input action | UInputAction* | nullptr |
AimAction | The aim down sights input action | UInputAction* | nullptr |
EquipNextWeaponAction | The equip next weapon input action | UInputAction* | nullptr |
EquipPreviousWeaponAction | The equip previous weapon input action | UInputAction* | nullptr |
ReloadWeaponAction | The reload weapon input action | UInputAction* | nullptr |
CrouchAction | The crouch input action | UInputAction* | nullptr |
ProneAction | The prone input action | UInputAction* | nullptr |
LeanAction | The lean input action | UInputAction* | nullptr |
InteractAction | The interact input action | UInputAction* | nullptr |
SwitchCameraPerspectiveAction | The switch camera perspective input action | UInputAction* | nullptr |
CameraPerspective | The camera perspective used by the character | ECameraPerspective | |
bCanSwitchCameraPerspectives | Can the character switch perspectives? | bool | true |
bSmoothCameraRotation | Should the camera rotation be smooth or instant? | bool | false |
SmoothCameraRotationSpeed | The speed used to smooth the camera rotations | float | 5.0f |
HeadSocketName | The name of the head socket used to attach the camera in the first person perspective | FName | |
CameraAttachOffset | The offset of the camera after attaching to the head | FVector | |
TargetArmLength | Length of the spring arm component | float | 350.0f |
ArmLengthMultiplier | The multiplier applied to the spring arm component when the character is moving | float | 0.4f |
CameraAdjustmentSpeed | The speed used when adjusting the camera distance | float | 3.0f |
ShadowDecalClass | The shadow decal class used to draw a shadow below the character while in the air | TSubclassOf<AShadowDecal> | |
JumpSoundEffects | An array of sound effects played when jumping | TArray<USoundBase*> | |
JumpParticleFx | The particle effects spawned when jumping | UNiagaraSystem* | nullptr |
JumpParticleFxSpawnOffset | The offset applied to the location of the jump particles when spawning | FVector | |
LandedSoundEffects | An array of sound effects played when landing | TArray<USoundBase*> | |
LandParticleFx | The particle effects spawned when landing | UNiagaraSystem* | nullptr |
LandParticleFxSpawnOffset | The offset applied to the location of the land particles when spawning | FVector | |
VariableJumpHeight | Does the character support variable jump height? | bool | true |
VariableJumpHeightMaxHoldTime | The amount of time to hold the jump button to reach the max height | float | 0.3f |
JumpVelocity | The velocity applied to the character when jumping | float | 500.0f |
AirControl | The amount of lateral movement control available to the character while in the air | float | 1000.0f |
FallingFriction | The amount of friction to apply to lateral air movement when falling | float | 3.5f |
Gravity | The amount of gravity applied to the character | float | 2.0f |
CanDoubleJump | Can the character perform a double jump? | bool | true |
CanCoyoteJump | Does the character support coyote time when trying to jump? | bool | true |
CoyoteJumpTime | The amount of coyote time for the character | float | 0.375f |
CoyoteJumpVelocity | The velocity applied to the character when performing a coyote jump | float | 700.0f |
bCanStompJump | Can the character perform a high jump directly after landing from a stomp? | bool | true |
StompJumpDuration | The duration after the stomp that the character can perform the stomp jump | float | 0.35f |
StompJumpVelocity | The velocity applied to the character when performing a stomp jump | float | 1250.0f |
bCanCrouchJump | Can the character perform a high jump while crouching? | bool | true |
CrouchJumpVelocity | The velocity applied to the character when performing a crouch jump | float | 1250.0f |
IsDoubleJumping | Is the character double jumping? | bool | false |
bCanLongJump | Is the character allowed to perform a long jump? | bool | true |
LongJumpVelocity | The velocity applied to the character during a long jump | FVector | FVecto |
MovementSpeed | The default movement speed | float | 600.0f |
BrakingFriction | Friction coefficient applied when braking | float | 10.0f |
MaxAcceleration | The rate of change of velocity | float | 2500.0f |
bSmoothMovement | Should the movement be smooth or instant? | bool | false |
SmoothMovementSpeed | The speed used to smooth the movement | float | 5.0f |
bCanSprint | Can the character sprint? | bool | true |
SprintSpeed | The movement speed while the character is sprinting | float | 950.0f |
bSprintRequiresStamina | Does sprinting require stamina? | bool | false |
SprintStaminaStatName | The name of the stamina stat used for sprinting | FName | |
SprintStaminaUseRate | The amount of stamina used per second while sprinting | float | 20.0f |
bCanCrouch | Can the character crouch? | bool | true |
bHoldToCrouch | Should the crouch/prone action be held down to crouch? | bool | true |
CrouchSpeed | The movement speed while the character is crouching | float | 300.0f |
CrouchCurve | The float curve used for smooth crouching | UCurveFloat* | nullptr |
bCanProne | Can the character prone? | bool | true |
bHoldToProne | Should the crouch/prone action be held down to prone? | bool | true |
ProneTraceHeight | The height of the trace used to check if the character can prone | float | 5.0f |
ProneTraceOffsetZ | The Z-offset of the trace used to check if the character can prone | float | -20.0f |
ProneMoveTraceSizeMultiplier | The multiplier applied to the trace size when the character is moving while proning | float | 0.5f |
ProneSpeed | The movement speed while the character is proning | float | 100.0f |
ProneCurve | The float curve used for smooth proning | UCurveFloat* | nullptr |
bCanStomp | Can the character perform a stomp? | bool | true |
MinAirTimeBeforeStomping | The minimum air time before the character can perform a stomp | float | 0.3f |
StompVelocity | The velocity applied to the character after performing a stomp | float | -5000.0f |
StompZeroGravityDuration | The amount of time the character will be in zero gravity after performing a stomp | float | 0.5f |
StompLandVelocity | The velocity applied to the character when landing after performing a stomp | float | 750.0f |
StompRecoveryTime | The time it takes (in seconds) before the character recovers from a stomp and can move again | float | 0.25f |
StompCameraShake | The camera shake applied when performing a stomp | TSubclassOf<UCameraShakeBase> | |
bCanLean | Can the character lean? | bool | true |
LeanSpeed | The speed used when leaning | float | 5.0f |
LeanOffset | The offset applied to the camera when leaning | float | 50.0f |
LeanRotation | The rotation applied to the camera when leaning | float | 25.0f |
bLookAtCenterWhileIdle | Should the character automatically rotate to look at the center of the screen while idle? | bool | true |
MaxLookAtCenterRotationWhileIdle | The maximum rotation that can be applied while looking at the center of the screen while idle | float | 90.0f |
bLookAtCenterWhileRunning | Should the character automatically rotate to look at the center of the screen while running? | bool | true |
MaxLookAtCenterRotationWhileRunning | The maximum rotation that can be applied while looking at the center of the screen while running | float | 90.0f |
bLookAtCenterWhileSprinting | Should the character automatically rotate to look at the center of the screen while sprinting? | bool | true |
MaxLookAtCenterRotationWhileSprinting | The maximum rotation that can be applied while looking at the center of the screen while sprinting | float | 90.0f |
bLookAtCenterWhileCrouching | Should the character automatically rotate to look at the center of the screen while crouching? | bool | true |
MaxLookAtCenterRotationWhileCrouching | The maximum rotation that can be applied while looking at the center of the screen while crouching | float | 60.0f |
bLookAtCenterWhileProning | Should the character automatically rotate to look at the center of the screen while proning? | bool | true |
MaxLookAtCenterRotationWhileProning | The maximum rotation that can be applied while looking at the center of the screen while proning | float | 45.0f |
LookAtCenterCurve | The float curve used to look at the center of the screen | UCurveFloat* | nullptr |
bCanSlide | Can the character perform a slide? | bool | true |
SlideSpeed | The movement speed while the character is sliding | float | 2500.0f |
bSlideRequiresSprinting | Does sliding require the character to sprint? | bool | false |
SlideMinSpeed | The minimum movement speed before a slide is allowed | float | 400.0f |
SlidingTime | The time the character is allowed to slide | float | 0.5f |
SlidingCooldown | The cooldown after a slide before another slide can be performed | float | 0.5f |
SlideSoundEffects | The sound effect played when the character is sliding | TArray<USoundBase*> | |
MaxWeapons | The maximum amount of weapons that the character can carry | int | 2 |
DefaultWeaponClass | The default weapon the character will equip on spawn | TSubclassOf<AWeapon> | |
AimCurve | The float curve used for aiming | UCurveFloat* | nullptr |
DefaultCrosshair | The default crosshair to use if no weapon is equipped | UCrosshairConfig* | nullptr |
Events
Name | Description | Params |
---|---|---|
OnCurrentWeaponUpdated | Event used to notify other classes when the weapon is updated | Weapon (AWeapon*) The current weapon used by the character Ammo (AWeapon*) The amount of ammo remaining ReloadAmmo (AWeapon*) The amount of ammo that can be used to reload the weapon |
OnCrosshairUpdated | Event used to notify other classes that the crosshair is updated | Crosshair (UCrosshairConfig*) The current crosshair config |
Functions
Name | Description | Params | Return |
---|---|---|---|
GetCameraComponent | Get the camera used by the character | UCameraComponent* The camera used by the character |
|
GetSpringArmComponent | Get the spring arm component of the character | USpringArmComponent* The spring arm component responsible for controlling the distance of the camera |
|
GetCameraPerspective | Get the current camera perspective | ECameraPerspective The current camera perspective |
|
UpdateCameraPerspective | Update the current camera perspective | NewCameraPerspective (ECameraPerspective) The new camera perspective |
|
SwitchCameraPerspective | Switch the current camera perspective | ||
SetWeapon | Set the current weapon used by the character | NewWeapon (AWeapon*) The new weapon |
|
GetWeapon | Get the current weapon used by the character | AWeapon* The current weapon used by the character |
|
HasWeapon | Check if the character has a weapon | bool A boolean value indicating if the character has a weapon |
|
IsCrouching | Check if the character is crouching | bool A boolean value indicating if the character is crouching |
|
IsProning | Check if the character is proning | bool A boolean value indicating if the character is proning |
|
IsEndingCrouch | Check if the character is busy ending the crouch | bool A boolean value indicating if the character is busy ending the crouch |
|
IsEndingProne | Check if the character is busy ending the prone | bool A boolean value indicating if the character is busy ending the prone |
|
IsStomping | Check if the character is stomping | bool A boolean value indicating if the character is stomping |
|
IsStompStarting | Check if the character is starting to stomp | bool A boolean value indicating if the character is starting to stomp |
|
GetLeanCameraRoll | Get the current lean camera roll | float The current lean camera roll |
|
GetLookAtCenterRotation | Get the look at center rotation | float The look at center rotation |
|
IsSliding | Check if the character is sliding | bool A boolean value indicating if the character is sliding |
|
IsEndingSlide | Check if the character is busy ending the slide | bool A boolean value indicating if the character is busy ending the slide |
|
GetInteractTrigger | Get the current interact trigger | UInteractTrigger* The current interact trigger |
|
UpdateInteractTrigger | Update the current interact trigger | NewInteractTrigger (UInteractTrigger*) The new interact trigger |
|
OnWeaponUpdated | Called when the current weapon is updated | ||
OnNewWeaponEquipped | Called when a new weapon is equipped for the first time | Weapon (AWeapon*) The new weapon that was equipped |
|
IsAiming | Check if the character is aiming | bool A boolean value indicating if the character is aiming |
|
GetCrosshair | Get the crosshair configuration | UCrosshairConfig* The crosshair configuration |
|
GetWeaponSway | Get the current weapon sway rotation | FRotator The current weapon sway rotation |
|
StartFiringWeapon | Start firing the current weapon | ||
StopFiringWeapon | Stop firing the current weapon | ||
EquipNextWeapon | Equip the next weapon in the list of available weapons | ||
EquipPreviousWeapon | Equip the previous weapon in the list of available weapons | ||
StartCrouching | Start crouching | ||
StopCrouching | Stop crouching | ||
StartProning | Start proning | ||
StopProning | Stop proning | ||
UpdateCharacterMeshLocationWhileCrouching | Update the character mesh location while crouching | SizeDifference (float) The difference between the original capsule size and the crouched capsule size |
Blueprint Usage
There is no additional functions exposed to Blueprints. Just create the character and add it to your level