Update DismemberedAnimInstance.cpp
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
UDismemberedAnimInstance::UDismemberedAnimInstance()
|
UDismemberedAnimInstance::UDismemberedAnimInstance()
|
||||||
{
|
{
|
||||||
// 初始化成员变量
|
//Initialize member variables
|
||||||
SourceBoneName = NAME_None;
|
SourceBoneName = NAME_None;
|
||||||
CutType = 0;
|
CutType = 0;
|
||||||
RootBoneName = NAME_None;
|
RootBoneName = NAME_None;
|
||||||
@@ -19,10 +19,10 @@ void UDismemberedAnimInstance::NativeUpdateAnimation(float DeltaSeconds)
|
|||||||
{
|
{
|
||||||
Super::NativeUpdateAnimation(DeltaSeconds);
|
Super::NativeUpdateAnimation(DeltaSeconds);
|
||||||
|
|
||||||
// 更新动画逻辑
|
//Update animation logic
|
||||||
// 可以根据LinearVelocity和AngularVelocity更新动画状态
|
// You can update the animation state based on LinearVelocity and AngularVelocity
|
||||||
|
|
||||||
// 随时间衰减速度
|
// Decay speed over time
|
||||||
const float DampingFactor = 0.95f;
|
const float DampingFactor = 0.95f;
|
||||||
LinearVelocity *= DampingFactor;
|
LinearVelocity *= DampingFactor;
|
||||||
AngularVelocity *= DampingFactor;
|
AngularVelocity *= DampingFactor;
|
||||||
@@ -32,14 +32,14 @@ void UDismemberedAnimInstance::NativeInitializeAnimation()
|
|||||||
{
|
{
|
||||||
Super::NativeInitializeAnimation();
|
Super::NativeInitializeAnimation();
|
||||||
|
|
||||||
// 获取拥有者骨骼网格体
|
// Get the owner skeleton mesh
|
||||||
USkeletalMeshComponent* OwnerMesh = GetSkelMeshComponent();
|
USkeletalMeshComponent* OwnerMesh = GetSkelMeshComponent();
|
||||||
if (!OwnerMesh)
|
if (!OwnerMesh)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化动画相关参数
|
// Initialize animation related parameters
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDismemberedAnimInstance::SetSourceBone(const FName& BoneName)
|
void UDismemberedAnimInstance::SetSourceBone(const FName& BoneName)
|
||||||
@@ -54,10 +54,10 @@ void UDismemberedAnimInstance::SetCutType(int32 InCutType)
|
|||||||
|
|
||||||
void UDismemberedAnimInstance::ApplyImpulse(const FVector& Impulse)
|
void UDismemberedAnimInstance::ApplyImpulse(const FVector& Impulse)
|
||||||
{
|
{
|
||||||
// 应用冲量到分离的部分
|
// Apply impulse to the separated part
|
||||||
LinearVelocity += Impulse;
|
LinearVelocity += Impulse;
|
||||||
|
|
||||||
// 根据冲量生成一些随机的角速度
|
// Generate some random angular velocity based on the impulse
|
||||||
const float AngularImpulseFactor = 0.1f;
|
const float AngularImpulseFactor = 0.1f;
|
||||||
FVector RandomAngular = FVector(
|
FVector RandomAngular = FVector(
|
||||||
FMath::RandRange(-1.0f, 1.0f),
|
FMath::RandRange(-1.0f, 1.0f),
|
||||||
@@ -66,4 +66,4 @@ void UDismemberedAnimInstance::ApplyImpulse(const FVector& Impulse)
|
|||||||
);
|
);
|
||||||
|
|
||||||
AngularVelocity += RandomAngular * Impulse.Size() * AngularImpulseFactor;
|
AngularVelocity += RandomAngular * Impulse.Size() * AngularImpulseFactor;
|
||||||
}
|
}
|
Reference in New Issue
Block a user