Character (HCharacter)
The HCharacter class extends Actor and spawns a customizable player character into the world with support for animation, mesh overrides, ragdoll physics, and attachments. It is designed for gameplay characters that need full control over visuals, input, skeletal sockets, and interactions. This class is ideal for roleplay systems, test bots, or any scenario where you need a fully controllable humanoid character.
tip
HCharacter is an Actor, so it inherits all functions from Actor.
Constructor
- Blueprint
- Lua
- JavaScript
// Characters are spawned via Lua scripting on the server.
-- Spawn a character and possess it
local char = HCharacter(Vector(0, 0, 100), Quat(0, 0, 0, 1), player)
player:Possess(char:GetPawn())
// Character spawning follows the same pattern via PuerTS or Helix JS bindings.
// Refer to the Lua examples for constructor parameters.
Constructor Parameters
| Name | Type | Default | Description |
|---|---|---|---|
location | Vector | (0,100,100) | Spawn position. |
rotation | Quat | (0,0,0,1) | Spawn orientation. |
player | APlayerController | Required | Player controller to possess the character. |
collision_type | string | "Pawn" | Collision profile. |
gravity_enabled | boolean | true | Whether gravity is applied to the pawn. |
max_health | number | 100 | Character's starting health. |
death_sound | SoundCue | nil | Optional death sound. |
pain_sound | SoundCue | nil | Optional hurt sound. |
Methods
| Method | Parameters | Return Type | Authority | Description |
|---|---|---|---|---|
PlayAnimation | Montage: AnimMontage, PlayRate: number, StartSection: string | void | Both | Plays a montage animation on the character. |
StopAnimation | BlendOut: number, Montage: AnimMontage | void | Both | Stops an active montage with an optional blend-out time. |
AddStaticMeshAttached | ID: string, Mesh: StaticMesh, BoneName: string | void | Both | Attaches a static mesh to a bone/socket on the character. |
RemoveStaticMeshAttached | ID: string | void | Both | Removes a previously attached mesh by ID. |
RemoveAllStaticMeshesAttached | -- | void | Both | Removes all attached meshes from the character. |
SetInputEnabled | bEnabled: boolean | void | Server | Enables or disables player input for movement and look. |
SetRagdollMode | bEnabled: boolean | void | Both | Toggles ragdoll physics on or off. |
SetMesh | Mesh: SkeletalMesh | void | Both | Overrides the character's skeletal mesh. |
GetPawn | -- | ACharacter | Both | Returns the underlying ACharacter actor. |
GetPlayer | -- | APlayerController | Both | Returns the controlling APlayerController. |
GetTeam | -- | number | Both | Returns the team value assigned to the character. |
GetMesh | -- | string | Both | Returns the name of the currently assigned skeletal mesh. |
GetBoneTransform | BoneName: string | FTransform | Both | Returns a FTransform for a bone name (e.g., "hand_r"). |
IsInRagdollMode | -- | boolean | Both | Returns true if ragdoll physics are currently active. |
IsInputEnabled | -- | boolean | Both | Returns whether input is currently enabled. |
Examples
Playing an Animation
- Blueprint
- Lua
- JavaScript
// Play an animation montage on the character via Lua scripting.
-- Play a montage animation
char:PlayAnimation(MyMontage, 1.0, "StartSection")
-- Stop the animation with a blend-out
char:StopAnimation(0.25, MyMontage)
// Animation playback follows the same pattern via PuerTS or Helix JS bindings.
// Refer to the Lua examples for function signatures.
Attaching Meshes
- Blueprint
- Lua
- JavaScript
// Mesh attachment is handled via Lua scripting.
-- Attach a backpack mesh to a bone
char:AddStaticMeshAttached("bag", BagMesh, "spine_03")
-- Remove it later
char:RemoveStaticMeshAttached("bag")
// Mesh attachment follows the same pattern.
// Refer to the Lua examples for function signatures.
Ragdoll Mode
- Blueprint
- Lua
- JavaScript
// Ragdoll mode is toggled via Lua scripting.
-- Enable ragdoll physics
char:SetRagdollMode(true)
-- Check if in ragdoll
if char:IsInRagdollMode() then
print("Character is ragdolling")
end
// Ragdoll mode follows the same pattern.
// Refer to the Lua examples for function signatures.
note
Player characters are spawned by passing the player controller to the HCharacter constructor. The player controller then possesses the character's pawn via player:Possess(char:GetPawn()).