HCharacter
/// tip
HCharacter is an Actor so it inherits all functions from Actor
///
Constructorโ
local char = HCharacter(Vector(0,0,100), Quat(0,0,0,1), player)
player:Possess(char:GetPawn())
| 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 |
Functionsโ
PlayAnimationโ
Plays a montage animation on the character.
char:PlayAnimation(MyMontage, 1.0, "StartSection")
StopAnimationโ
Stops an active montage with an optional blend-out.
char:StopAnimation(0.25, MyMontage)
AddStaticMeshAttachedโ
Attaches a static mesh to a bone/socket on the character.
char:AddStaticMeshAttached("bag", BagMesh, "spine_03")
RemoveStaticMeshAttachedโ
Removes a previously attached mesh by ID.
char:RemoveStaticMeshAttached("bag")
RemoveAllStaticMeshesAttachedโ
Removes all attached meshes from the character.
char:RemoveAllStaticMeshesAttached()
SetInputEnabledโ
Enables or disables player input for movement and look.
char:SetInputEnabled(false)
SetRagdollModeโ
Toggles ragdoll physics on or off.
char:SetRagdollMode(true)
SetMeshโ
Overrides the characterโs skeletal mesh.
char:SetMesh(UE.UObject.Load("/Game/MyMeshes/MyCustomMesh.MyCustomMesh"))
GetPawnโ
Returns the underlying ACharacter actor.
local pawn = char:GetPawn()
GetPlayerโ
Returns the controlling APlayerController.
local pc = char:GetPlayer()
GetTeamโ
Returns the team value assigned to the character.
local t = char:GetTeam()
GetMeshโ
Returns the name of the currently assigned skeletal mesh.
print(char:GetMesh())
GetBoneTransformโ
Returns a FTransform for a bone name (e.g., "hand_r").
local transform = char:GetBoneTransform("spine_03")
IsInRagdollModeโ
Returns true if ragdoll physics are currently active.
if char:IsInRagdollMode() then ...
IsInputEnabledโ
Returns whether input is currently enabled.
print(char:IsInputEnabled())