Loading...
Loading...
Compare original and translation side by side
UCharacterMovementComponentFSavedMove_CharacterUCharacterMovementComponentFSavedMove_Character.agents/ue-project-context.mdACharacterGravityDirectionDoJump.agents/ue-project-context.mdACharacterGravityDirectionDoJumpUCharacterMovementComponentUCharacterMovementComponentUCharacterMovementComponentUMovementComponent
-> UNavMovementComponent
-> UPawnMovementComponent
-> UCharacterMovementComponentIRVOAvoidanceInterfaceINetworkPredictionInterfaceUCLASS(MinimalAPI)ACharacterACharacterJumpCrouchLaunchCharacterUCharacterMovementComponentUMovementComponent
-> UNavMovementComponent
-> UPawnMovementComponent
-> UCharacterMovementComponentIRVOAvoidanceInterfaceINetworkPredictionInterfaceUCLASS(MinimalAPI)ACharacterACharacterJumpCrouchLaunchCharacterEMovementMode| Mode | Value | Description |
|---|---|---|
| 0 | No movement processing |
| 1 | Ground movement with floor detection and step-up |
| 2 | Walking driven by navmesh projection |
| 3 | Airborne — gravity, air control, landing detection |
| 4 | Fluid movement with buoyancy |
| 5 | Free 3D movement, no gravity |
| 6 | User-defined; dispatches to |
| 7 | Sentinel value |
SetMovementMode(EMovementMode, uint8 CustomMode = 0)OnMovementModeChanged(PreviousMode, PreviousCustomMode)EMovementMode| 模式 | 数值 | 描述 |
|---|---|---|
| 0 | 无移动处理 |
| 1 | 带地面检测和台阶攀爬的地面移动 |
| 2 | 由导航网格投影驱动的行走 |
| 3 | 空中状态——重力、空中控制、落地检测 |
| 4 | 带浮力的流体移动 |
| 5 | 自由3D移动,无重力 |
| 6 | 用户自定义;通过 |
| 7 | 哨兵值 |
SetMovementMode(EMovementMode, uint8 CustomMode = 0)OnMovementModeChanged(PreviousMode, PreviousCustomMode)PerformMovement(float DeltaTime)StartNewPhysics()Phys*EMovementModePhys*protected virtualPhysWalking(float deltaTime, int32 Iterations)PhysNavWalking(float deltaTime, int32 Iterations)PhysFalling(float deltaTime, int32 Iterations)PhysSwimming(float deltaTime, int32 Iterations)PhysFlying(float deltaTime, int32 Iterations)PhysCustom(float deltaTime, int32 Iterations)Phys*CalcVelocity// BlueprintCallable
void CalcVelocity(float DeltaTime, float Friction, bool bFluid, float BrakingDeceleration);SafeMoveUpdatedComponentvirtual bool SafeMoveUpdatedComponent(
const FVector& Delta,
const FQuat& NewRotation,
bool bSweep,
FHitResult& OutHit,
ETeleportType Teleport = ETeleportType::None
);MoveUpdatedComponentSafeMoveUpdatedComponentMoveUpdatedComponentSlideAlongSurfaceTwoWallAdjustUMovementComponentPhysWalkingComputeGroundMovementDeltareferences/movement-pipeline.mdPerformMovement(float DeltaTime)StartNewPhysics()EMovementModePhys*Phys*protected virtualPhysWalking(float deltaTime, int32 Iterations)PhysNavWalking(float deltaTime, int32 Iterations)PhysFalling(float deltaTime, int32 Iterations)PhysSwimming(float deltaTime, int32 Iterations)PhysFlying(float deltaTime, int32 Iterations)PhysCustom(float deltaTime, int32 Iterations)Phys*CalcVelocity// BlueprintCallable
void CalcVelocity(float DeltaTime, float Friction, bool bFluid, float BrakingDeceleration);SafeMoveUpdatedComponentvirtual bool SafeMoveUpdatedComponent(
const FVector& Delta,
const FQuat& NewRotation,
bool bSweep,
FHitResult& OutHit,
ETeleportType Teleport = ETeleportType::None
);MoveUpdatedComponentSafeMoveUpdatedComponentMoveUpdatedComponentSlideAlongSurfaceTwoWallAdjustUMovementComponentPhysWalkingComputeGroundMovementDeltareferences/movement-pipeline.mdstruct FFindFloorResult
{
uint32 bBlockingHit : 1; // Sweep hit something
uint32 bWalkableFloor : 1; // Hit surface passes walkability test
uint32 bLineTrace : 1; // Result came from line trace (not sweep)
float FloorDist; // Distance from capsule bottom to floor
float LineDist; // Distance from line trace
FHitResult HitResult; // Full hit result data
bool IsWalkableFloor() const { return bBlockingHit && bWalkableFloor; }
};struct FFindFloorResult
{
uint32 bBlockingHit : 1; // 扫查命中物体
uint32 bWalkableFloor : 1; // 命中表面通过可行走测试
uint32 bLineTrace : 1; // 结果来自线迹检测(而非扫查)
float FloorDist; // 胶囊底部到地面的距离
float LineDist; // 线迹检测的距离
FHitResult HitResult; // 完整的命中结果数据
bool IsWalkableFloor() const { return bBlockingHit && bWalkableFloor; }
};FindFloorvoid FindFloor(
const FVector& CapsuleLocation,
FFindFloorResult& OutFloorResult,
bool bCanUseCachedLocation,
const FHitResult* DownwardSweepResult = nullptr
);ComputeFloorDist()FindFloorvoid FindFloor(
const FVector& CapsuleLocation,
FFindFloorResult& OutFloorResult,
bool bCanUseCachedLocation,
const FHitResult* DownwardSweepResult = nullptr
);ComputeFloorDist()WalkableFloorAngleWalkableFloorZSetWalkableFloorAngle()WalkableFloorAngleWalkableFloorZSetWalkableFloorAngle()MOVE_Customuint8uint8MOVE_CustomUENUM(BlueprintType)
enum class ECustomMovementMode : uint8
{
WallRun = 0,
Climb = 1,
Dash = 2
};PhysCustomvirtual void PhysCustom(float deltaTime, int32 Iterations) override;SetMovementModeSetMovementMode(MOVE_Custom, static_cast<uint8>(ECustomMovementMode::WallRun));OnMovementModeChangedvirtual void OnMovementModeChanged(EMovementMode PrevMode, uint8 PrevCustomMode) override;PhysCustomCustomMovementModeCalcVelocitySafeMoveUpdatedComponentSetMovementModereferences/cmc-extension-patterns.mdUENUM(BlueprintType)
enum class ECustomMovementMode : uint8
{
WallRun = 0,
Climb = 1,
Dash = 2
};PhysCustomvirtual void PhysCustom(float deltaTime, int32 Iterations) override;SetMovementModeSetMovementMode(MOVE_Custom, static_cast<uint8>(ECustomMovementMode::WallRun));OnMovementModeChangedvirtual void OnMovementModeChanged(EMovementMode PrevMode, uint8 PrevCustomMode) override;PhysCustomCustomMovementModeCalcVelocitySafeMoveUpdatedComponentSetMovementModereferences/cmc-extension-patterns.mdbPressedJumpbWantsToCrouchStartLocationStartVelocitySavedLocationAccelerationMaxSpeedClear()SetMoveFor(ACharacter*, float, FVector const&, FNetworkPredictionData_Client_Character&)PrepMoveFor(ACharacter*)GetCompressedFlags() constuint8CanCombineWith(const FSavedMovePtr&, ACharacter*, float)truePostUpdate(ACharacter*, EPostUpdateMode)IsImportantMove(const FSavedMovePtr&)bPressedJumpbWantsToCrouchStartLocationStartVelocitySavedLocationAccelerationMaxSpeedClear()SetMoveFor(ACharacter*, float, FVector const&, FNetworkPredictionData_Client_Character&)PrepMoveFor(ACharacter*)GetCompressedFlags() constuint8CanCombineWith(const FSavedMovePtr&, ACharacter*, float)truePostUpdate(ACharacter*, EPostUpdateMode)IsImportantMove(const FSavedMovePtr&)uint8GetCompressedFlags| Flag | Value | Purpose |
|---|---|---|
| | Jump input |
| | Crouch input |
| | Engine reserved |
| | Engine reserved |
| | Your custom flag |
| | Your custom flag |
| | Your custom flag |
| | Your custom flag |
FCharacterNetworkMoveDataGetCompressedFlagsuint8| 标志 | 数值 | 用途 |
|---|---|---|
| | 跳跃输入 |
| | 蹲伏输入 |
| | 引擎保留 |
| | 引擎保留 |
| | 自定义标志 |
| | 自定义标志 |
| | 自定义标志 |
| | 自定义标志 |
FCharacterNetworkMoveDataAllocateNewMove()FSavedMoveclass FMyNetworkPredictionData : public FNetworkPredictionData_Client_Character
{
public:
FMyNetworkPredictionData(const UCharacterMovementComponent& ClientMovement)
: FNetworkPredictionData_Client_Character(ClientMovement) {}
virtual FSavedMovePtr AllocateNewMove() override;
};GetPredictionData_Client()AllocateNewMove()FSavedMoveclass FMyNetworkPredictionData : public FNetworkPredictionData_Client_Character
{
public:
FMyNetworkPredictionData(const UCharacterMovementComponent& ClientMovement)
: FNetworkPredictionData_Client_Character(ClientMovement) {}
virtual FSavedMovePtr AllocateNewMove() override;
};GetPredictionData_Client()ACharacterServerMovePacked(FCharacterServerMovePackedBits)ClientMoveResponsePacked(FCharacterMoveResponsePackedBits)ServerMoveServerMoveDualClientAdjustPositionDEPRECATED_CHARACTER_MOVEMENT_RPCFCharacterNetworkMoveDataClientFillNetworkMoveDataSerializeFCharacterNetworkMoveDataContainerSetNetworkMoveDataContainer()references/cmc-extension-patterns.mdACharacterServerMovePacked(FCharacterServerMovePackedBits)ClientMoveResponsePacked(FCharacterMoveResponsePackedBits)ServerMoveServerMoveDualClientAdjustPositionDEPRECATED_CHARACTER_MOVEMENT_RPCFCharacterNetworkMoveDataClientFillNetworkMoveDataSerializeFCharacterNetworkMoveDataContainerSetNetworkMoveDataContainer()references/cmc-extension-patterns.mdFRootMotionSourceFRootMotionSourcePriorityLocalIDApplyRootMotionSourceInstanceNameFNameDurationAccumulateModeOverrideAdditivePriorityLocalIDApplyRootMotionSourceInstanceNameFNameDurationAccumulateModeOverrideAdditive| Class | Key Parameters | Use Case |
|---|---|---|
| | Knockback, wind |
| | Explosions, vortex |
| | Dash to fixed point |
| | Homing dash |
| | Targeted jump arc |
| 类 | 关键参数 | 使用场景 |
|---|---|---|
| | 击退、风力 |
| | 爆炸、漩涡 |
| | 冲刺到固定点 |
| | 追踪冲刺 |
| | 目标跳跃弧线 |
// Returns uint16 LocalID for tracking
uint16 ApplyRootMotionSource(TSharedPtr<FRootMotionSource> Source);
// Retrieve by InstanceName
TSharedPtr<FRootMotionSource> GetRootMotionSource(FName InstanceName);
// Remove by InstanceName
void RemoveRootMotionSource(FName InstanceName);auto Knockback = MakeShared<FRootMotionSource_ConstantForce>();
Knockback->InstanceName = TEXT("Knockback");
Knockback->Duration = 0.3f;
Knockback->Force = KnockbackDirection * KnockbackStrength;
Knockback->AccumulateMode = ERootMotionAccumulateMode::Override;
CMC->ApplyRootMotionSource(Knockback);// 返回用于追踪的uint16 LocalID
uint16 ApplyRootMotionSource(TSharedPtr<FRootMotionSource> Source);
// 通过InstanceName检索
TSharedPtr<FRootMotionSource> GetRootMotionSource(FName InstanceName);
// 通过InstanceName移除
void RemoveRootMotionSource(FName InstanceName);auto Knockback = MakeShared<FRootMotionSource_ConstantForce>();
Knockback->InstanceName = TEXT("Knockback");
Knockback->Duration = 0.3f;
Knockback->Force = KnockbackDirection * KnockbackStrength;
Knockback->AccumulateMode = ERootMotionAccumulateMode::Override;
CMC->ApplyRootMotionSource(Knockback);| Property | Default | Description |
|---|---|---|
| 600 | Maximum ground speed |
| — | Rate of speed change |
| 1.0 | Multiplier on world gravity |
| — | Initial vertical velocity on jump |
| — | Lateral control while falling (0-1) |
| — | Friction on ground surfaces |
| — | Deceleration when no input on ground |
| — | Maximum height of obstacles to step over |
| 44.765 | Max walkable surface angle in degrees |
| — | Speed while crouching |
| — | Maximum speed in water |
| — | Maximum speed when flying |
| — | Speed cap for custom modes |
| — | Rotate character toward movement direction |
| — | Smoothly rotate toward controller rotation |
| — | Simulated proxy interpolation mode |
| — | Cap on sub-step delta for stability |
| — | Max physics iterations per frame |
| false | Enable RVO (reciprocal velocity obstacle) avoidance |
| — | |
| — | float — higher weight yields right-of-way to other agents |
| 属性 | 默认值 | 描述 |
|---|---|---|
| 600 | 最大地面移动速度 |
| — | 速度变化率 |
| 1.0 | 世界重力的乘数 |
| — | 跳跃时的初始垂直速度 |
| — | 下落时的横向控制(0-1) |
| — | 地面表面的摩擦力 |
| — | 地面无输入时的减速度 |
| — | 可攀爬的障碍物最大高度 |
| 44.765 | 最大可行走表面角度(度) |
| — | 蹲伏时的速度 |
| — | 水中最大速度 |
| — | 飞行时的最大速度 |
| — | 自定义模式的速度上限 |
| — | 使角色朝向移动方向旋转 |
| — | 平滑地朝向控制器旋转方向 |
| — | 模拟代理的插值模式 |
| — | 子步delta的上限,保证稳定性 |
| — | 每帧最大物理迭代次数 |
| false | 启用RVO(相对速度障碍物)避让 |
| — | |
| — | float —— 权重越高,越优先获得通行权 |
bOrientRotationToMovementbUseControllerDesiredRotationbOrientRotationToMovementbUseControllerDesiredRotationvirtual void SetGravityDirection(const FVector& GravityDir);
FVector GetGravityDirection() const;
bool HasCustomGravity() const;
// Transform helpers (fields are protected — access via accessors)
FQuat GetWorldToGravityTransform() const;
FQuat GetGravityToWorldTransform() const;HasCustomGravity()truevirtual void SetGravityDirection(const FVector& GravityDir);
FVector GetGravityDirection() const;
bool HasCustomGravity() const;
// 变换助手(字段受保护——通过访问器访问)
FQuat GetWorldToGravityTransform() const;
FQuat GetGravityToWorldTransform() const;HasCustomGravity()trueACharacterACharactervoid Jump(); // Sets bPressedJump, CMC handles velocity
void StopJumping(); // Clears jump input
bool CanJump() const; // Checks CanJumpInternalbPressedJumpJumpMaxHoldTimeJumpMaxCountJumpCurrentCountDoJump(bool bReplayingMoves, float DeltaTime)DoJump(bool)void Jump(); // 设置bPressedJump,CMC处理速度
void StopJumping(); // 清除跳跃输入
bool CanJump() const; // 检查CanJumpInternalbPressedJumpJumpMaxHoldTimeJumpMaxCountJumpCurrentCountDoJump(bool bReplayingMoves, float DeltaTime)DoJump(bool)void Crouch(bool bClientSimulation = false);
void UnCrouch(bool bClientSimulation = false);bIsCrouchedCrouchedHalfHeightSetCrouchedHalfHeight()GetCrouchedHalfHeight()void Crouch(bool bClientSimulation = false);
void UnCrouch(bool bClientSimulation = false);bIsCrouchedCrouchedHalfHeightSetCrouchedHalfHeight()GetCrouchedHalfHeight()void LaunchCharacter(FVector LaunchVelocity, bool bXYOverride, bool bZOverride);bXYOverridetruefalsebZOverrideMOVE_Fallingvoid LaunchCharacter(FVector LaunchVelocity, bool bXYOverride, bool bZOverride);bXYOverridetruefalseMOVE_Fallingvirtual void Landed(const FHitResult& Hit);virtual void Landed(const FHitResult& Hit);UCharacterMovementComponent* GetCharacterMovement() const;
UCapsuleComponent* GetCapsuleComponent() const;
USkeletalMeshComponent* GetMesh() const;UCharacterMovementComponent* GetCharacterMovement() const;
UCapsuleComponent* GetCapsuleComponent() const;
USkeletalMeshComponent* GetMesh() const;// WRONG: Bypasses friction, braking, and acceleration curves
Velocity = GetLastInputVector() * MaxWalkSpeed;
// RIGHT: Let CMC handle physics
CalcVelocity(DeltaTime, GroundFriction, false, BrakingDecelerationWalking);// WRONG: Skips base class bookkeeping
void UMyCMC::PhysCustom(float DT, int32 Iter)
{
MyCustomLogic(DT, Iter);
}
// RIGHT: Call Super first (base PhysCustom is empty but future-proofs)
void UMyCMC::PhysCustom(float DT, int32 Iter)
{
Super::PhysCustom(DT, Iter);
MyCustomLogic(DT, Iter);
}SetMoveForPrepMoveForMoveUpdatedComponentSafeMoveUpdatedComponentbOrientRotationToMovementbUseControllerDesiredRotationServerMoveServerMoveDualClientAdjustPositionDEPRECATED_CHARACTER_MOVEMENT_RPCFCharacterNetworkMoveData// 错误:绕过了摩擦力、制动和加速度曲线
Velocity = GetLastInputVector() * MaxWalkSpeed;
// 正确:让CMC处理物理逻辑
CalcVelocity(DeltaTime, GroundFriction, false, BrakingDecelerationWalking);// 错误:跳过了基类的簿记工作
void UMyCMC::PhysCustom(float DT, int32 Iter)
{
MyCustomLogic(DT, Iter);
}
// 正确:先调用Super(基类PhysCustom为空,但这样做可兼容未来版本)
void UMyCMC::PhysCustom(float DT, int32 Iter)
{
Super::PhysCustom(DT, Iter);
MyCustomLogic(DT, Iter);
}SetMoveForPrepMoveForMoveUpdatedComponentSafeMoveUpdatedComponentbOrientRotationToMovementbUseControllerDesiredRotationServerMoveServerMoveDualClientAdjustPositionDEPRECATED_CHARACTER_MOVEMENT_RPCFCharacterNetworkMoveDatareferences/cmc-extension-patterns.mdreferences/movement-pipeline.mdreferences/cmc-extension-patterns.mdreferences/movement-pipeline.mdue-networking-replicationue-animation-systemue-physics-collisionue-gameplay-abilitiesue-ai-navigationue-input-systemue-actor-component-architectureue-networking-replicationue-animation-systemue-physics-collisionue-gameplay-abilitiesue-ai-navigationue-input-systemue-actor-component-architecture