ACharacter
#include "GameFramework/Character.h"
Access: public
Specifiers: UCLASS
Description
ACharacter extends APawn with a CapsuleComponent for collision, a SkeletalMeshComponent for visual representation, and a CharacterMovementComponent for walking, running, jumping, swimming, and flying. The most commonly used base class for player characters and NPCs.
Signature
class ACharacter : public APawn Caveats & Gotchas
- • The RootComponent of ACharacter is the CapsuleComponent. The mesh is a child of the capsule, typically positioned so the capsule feet sit at Z=0.
- • Do not override the CapsuleComponent radius/height in blueprints without updating the mesh offset to match.
- • CharacterMovementComponent uses network prediction. Understand the predicted/corrected movement model before customizing network movement.
- • Jump is handled by CharacterMovementComponent. Call `Jump()` and `StopJumping()` rather than manipulating velocity directly.
Example
ACharacter constructor C++
AMyCharacter::AMyCharacter()
{
// Capsule collision
GetCapsuleComponent()->InitCapsuleSize(42.f, 96.f);
// Character movement settings
GetCharacterMovement()->MaxWalkSpeed = 600.f;
GetCharacterMovement()->JumpZVelocity = 700.f;
GetCharacterMovement()->AirControl = 0.35f;
// Camera boom
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
CameraBoom->SetupAttachment(GetRootComponent());
CameraBoom->TargetArmLength = 400.f;
CameraBoom->bUsePawnControlRotation = true;
// Camera
FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);
} Functions (3)
Components 1 ▼
| Access | Type | Name |
|---|---|---|
| public | function | ACharacter::GetCharacterMovement |
Utility 2 ▼
| Access | Type | Name |
|---|---|---|
| public | function | ACharacter::Jump |
| public | function | ACharacter::LaunchCharacter |
Events & Delegates
See Also
Version History
Introduced in: 1.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?