engine
 
载入中...
搜索中...
未找到
Public 成员函数 | Public 属性 | 所有成员列表
FRootMotionSource结构体 参考

Generalized source of Root Motion to a CharacterMovementComponent. 更多...

#include <RootMotionSource.h>

+ 类 FRootMotionSource 继承关系图:

Public 成员函数

virtual void CheckTimeOut ()
 Checks if this source has timed out and marks for removal if necessary
 
virtual FRootMotionSource * Clone () const
 
float GetDuration () const
 
float GetStartTime () const
 
float GetTime () const
 
virtual bool IsActive () const
 True when this RootMotionSource should be affecting root motion
 
bool IsStartTimeValid () const
 
virtual bool IsTimeOutEnabled () const
 
virtual bool Matches (const FRootMotionSource *Other) const
 
virtual bool MatchesAndHasSameState (const FRootMotionSource *Other) const
 Checks that it Matches() and has the same state (time, track position, etc.)
 
virtual void PrepareRootMotion (float SimulationTime, float MovementTickTime, const ACharacter &Character, const UCharacterMovementComponent &MoveComponent)
 Generates the RootMotion for this Source, can be used for both "live" generation or for playback (client prediction correction, simulated proxies, etc.) 更多...
 
virtual void SetTime (float NewTime)
 Set the CurrentTime of this source. 更多...
 
virtual bool UpdateStateFrom (const FRootMotionSource *SourceToTakeStateFrom, bool bMarkForSimulatedCatchup=false)
 Mainly for server correction purposes - update this Source's state from another's, usually the authoritative state from the server's version of the Source 更多...
 

Public 属性

ERootMotionAccumulateMode AccumulateMode
 Accumulation mode for this source (whether or not to additively apply this root motion or override completely)
 
bool bInLocalSpace
 True when this RootMotionSource is contributing local space accumulation (false for world space)
 
bool bNeedsSimulatedCatchup
 True when this RootMotionSource has been marked for simulated catchup - this Simulated version of the Source needs to catch up to where it was before being corrected by authoritative version.
 
bool bSimulatedNeedsSmoothing
 True when this RootMotionSource is running on a SimulatedProxy and has marked itself as needing location/rotation smoothing. 更多...
 
float CurrentTime
 Time elapsed so far for this source
 
float Duration
 The length of this root motion - < 0 for infinite (to be removed manually)
 
FRootMotionFinishVelocitySettings FinishVelocityParams
 Finish Velocity Parameters
 
FName InstanceName
 This name allows us to find the source later so that we can end it.
 
uint16 LocalID
 ID local to this client or server instance. 更多...
 
float PreviousTime
 The last Time entry we had before the last SetTime() - used for simulated catchup
 
uint16 Priority
 Priority of this source relative to other sources - higher number being the highest priority/first applied.
 
FRootMotionMovementParams RootMotionParams
 Root Motion generated by this Source
 
FRootMotionSourceSettings Settings
 Settings of this source
 
float StartTime
 Time this source should start (in character movement client time) This is used to handle cases of inconsistent tick times (ServerMoves ticking for 1 second when root motion should have only applied for the last 0.1 seconds, or root motion source ending halfway through a 0.5 second tick)
 
FRootMotionSourceStatus Status
 Status of this source
 

详细描述

Generalized source of Root Motion to a CharacterMovementComponent.

Has priorities and different accumulation modes (override, additive, set, ignore).

RootMotionSources are accumulated from highest priority to lowest, once all values are "finalized" (meaning no more accumulation to those values), root motion accumulation is finished. Having all of translation and rotation in a transform being overridden during root motion accumulation means that CharacterMovementComponent Phys*() functions no longer need to CalcVelocity() since it'll just get overridden anyway.

Some example source possibilities: Full Animation Root Motion (matching only form of root motion we've supported historically):

Jump pad volumes that work during animation root montage attacks

Attack/melee homing

Character movement controlled by splines/curves in-editor instead of requiring animation tweaks

成员函数说明

◆ Clone()

virtual FRootMotionSource * FRootMotionSource::Clone ( ) const
virtual

◆ GetDuration()

float FRootMotionSource::GetDuration ( ) const
返回
the Duration - the length of this root motion - < 0 for infinite (to be removed manually)

◆ GetStartTime()

float FRootMotionSource::GetStartTime ( ) const
返回
the StartTime - time this source should start (in character movement client time)

◆ GetTime()

float FRootMotionSource::GetTime ( ) const
返回
the CurrentTime - amount of time elapsed so far for this source

◆ IsStartTimeValid()

bool FRootMotionSource::IsStartTimeValid ( ) const
返回
whether the start time has been set

◆ IsTimeOutEnabled()

virtual bool FRootMotionSource::IsTimeOutEnabled ( ) const
virtual
返回
whether this source will be removed when CurrentTime reaches Duration

被 FRootMotionSource_JumpForce 重载.

◆ Matches()

virtual bool FRootMotionSource::Matches ( const FRootMotionSource *  Other) const
virtual
返回
Whether this is the same RootMotionSource as Other. This is used for networking when clients receive RootMotionSource data from the server and need to decide which local RootMotionSource to compare and apply the corrections to. This is required due to RootMotionSources in general being added independently on server and clients, not needing to know about each other by default.

For well-networked RootMotionSources, any given FRootMotionSource child class could implement their own unique ID and simply use that in the Matches check. This "heuristic-style" default was chosen to simplify addition of new RootMotionSources, and assumes that in a networked setting a given RootMotionSource won't be applied many times in a given frame by the same instigator to the same target with the exact same parameters.

Guaranteed uniqueness would also require a strict application order ("RootMotionSources can only be added on Authority") or a prediction-based setup ("Apply on Autonomous and Simulated predictively, then apply on Authority and confirm, and if Authority doesn't confirm remove them"). We avoid that synchronization complexity for now.

See UCharacterMovementComponent::ConvertRootMotionServerIDsToLocalIDs

Should be overridden by child classes, as default implementation only contains basic equivalency checks

被 FRootMotionSource_ConstantForce, FRootMotionSource_RadialForce, FRootMotionSource_MoveToForce, FRootMotionSource_MoveToDynamicForce , 以及 FRootMotionSource_JumpForce 重载.

◆ PrepareRootMotion()

virtual void FRootMotionSource::PrepareRootMotion ( float  SimulationTime,
float  MovementTickTime,
const ACharacter &  Character,
const UCharacterMovementComponent &  MoveComponent 
)
virtual

Generates the RootMotion for this Source, can be used for both "live" generation or for playback (client prediction correction, simulated proxies, etc.)

Examples:

  • Animation RootMotionSources use Time as track time into AnimMontage and extract the root motion from AnimMontage chunk of time (Position,Position+DeltaTime)
  • ConstantForce source uses Time as the time into the application so if its duration ends halfway through the frame it knows how much root motion it should have applied
  • Spline/curve-based sources use Time for knowing where on spline/curve to extract from
    参数
    SimulationTimeHow far forward in time to simulate root motion
    MovementTickTimeHow much time the movement is going to take that this is being prepared for

被 FRootMotionSource_ConstantForce, FRootMotionSource_RadialForce, FRootMotionSource_MoveToForce, FRootMotionSource_MoveToDynamicForce , 以及 FRootMotionSource_JumpForce 重载.

◆ SetTime()

virtual void FRootMotionSource::SetTime ( float  NewTime)
virtual

Set the CurrentTime of this source.

Use this setter so that sources based on duration can get correctly marked for end

被 FRootMotionSource_MoveToForce , 以及 FRootMotionSource_MoveToDynamicForce 重载.

◆ UpdateStateFrom()

virtual bool FRootMotionSource::UpdateStateFrom ( const FRootMotionSource *  SourceToTakeStateFrom,
bool  bMarkForSimulatedCatchup = false 
)
virtual

Mainly for server correction purposes - update this Source's state from another's, usually the authoritative state from the server's version of the Source

参数
bMarkForSimulatedCatchupsets the source for needing to "catch up" to current state next Prepare
返回
Whether the update was sucessful or not. Note that failure to update denotes a complete failure, and the Source will then be marked for removal. We need to remove since we don't have a way of reverting partial updates depending on where the update failed.

被 FRootMotionSource_ConstantForce, FRootMotionSource_RadialForce, FRootMotionSource_MoveToForce, FRootMotionSource_MoveToDynamicForce , 以及 FRootMotionSource_JumpForce 重载.

类成员变量说明

◆ bSimulatedNeedsSmoothing

bool FRootMotionSource::bSimulatedNeedsSmoothing

True when this RootMotionSource is running on a SimulatedProxy and has marked itself as needing location/rotation smoothing.

This smoothing logic is what runs whenever the SimulatedProxy receives a replication update from the server (SimulatedTick in CharacterMovementComponent, see bCorrectedToServer and SmoothCorrection), this flag allows the RootMotionSource to signal to the CMC that a change was done significant enough that needs smoothing.

◆ LocalID

uint16 FRootMotionSource::LocalID

ID local to this client or server instance.

Used for matching up FRootMotionSources between SavedMoves and allow a mapping between server LocalIDs and client LocalIDs for correction/comparison


该结构体的文档由以下文件生成: