Refactored FeetPosition.
Addeed Blend profiles to stop -> start
This commit is contained in:
parent
ccfc21492d
commit
38e3ce0878
Binary file not shown.
Binary file not shown.
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "AnimInstances/OLSBaseLinkedLayerAnimInstance.h"
|
#include "AnimInstances/OLSBaseLinkedLayerAnimInstance.h"
|
||||||
|
|
||||||
|
#include "KismetAnimationLibrary.h"
|
||||||
#include "AnimInstances/OLSBaseLayerAnimInstance.h"
|
#include "AnimInstances/OLSBaseLayerAnimInstance.h"
|
||||||
|
|
||||||
void UOLSBaseLinkedLayerAnimInstance::NativeInitializeAnimation()
|
void UOLSBaseLinkedLayerAnimInstance::NativeInitializeAnimation()
|
||||||
@ -58,27 +59,32 @@ void UOLSBaseLinkedLayerAnimInstance::NativeThreadSafeUpdateSkeletonControlData(
|
|||||||
{
|
{
|
||||||
OrientationWarpingAlpha = GetCurveValue(EnableOrientationWarpingName);
|
OrientationWarpingAlpha = GetCurveValue(EnableOrientationWarpingName);
|
||||||
|
|
||||||
FeetPositionCurve = GetCurveValue(FeetPositionCurveName);
|
bIsLeftFootFarFromTarget = UKismetAnimationLibrary::K2_DistanceBetweenTwoSocketsAndMapRange(
|
||||||
bIsRightFootPlanted = FeetPositionCurve > FootPlantedThreshold;
|
GetOwningComponent(), FeetPositionSettings.IKFootLeft, RTS_World,
|
||||||
bIsLeftFootPlanted = FMath::Abs(FeetPositionCurve) > FootPlantedThreshold;
|
FeetPositionSettings.IKTargetFootLeft, RTS_World, false,
|
||||||
|
0.f, 0.f, 0.f, 0.f) > 8.0f;
|
||||||
|
|
||||||
|
bIsRightFootFarFromTarget = UKismetAnimationLibrary::K2_DistanceBetweenTwoSocketsAndMapRange(
|
||||||
|
GetOwningComponent(), FeetPositionSettings.IKFootRight, RTS_World,
|
||||||
|
FeetPositionSettings.IKTargetFootRight, RTS_World, false,
|
||||||
|
0.f, 0.f, 0.f, 0.f) > 8.0f;
|
||||||
|
|
||||||
// If neither foot is planted, use the last valid foot
|
// If neither foot is planted, use the last valid foot
|
||||||
if (!bIsRightFootPlanted && !bIsLeftFootPlanted)
|
if (!bIsRightFootFarFromTarget && !bIsLeftFootFarFromTarget)
|
||||||
{
|
{
|
||||||
if (bWasRightFootPlantingChanged)
|
if (bWasRightFootPlantingChanged)
|
||||||
{
|
{
|
||||||
bIsRightFootPlanted = true;
|
bIsRightFootFarFromTarget = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bIsLeftFootPlanted = true;
|
bIsLeftFootFarFromTarget = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Update the last valid foot
|
// Update the last valid foot
|
||||||
bWasRightFootPlantingChanged = bIsRightFootPlanted;
|
bWasRightFootPlantingChanged = bIsRightFootFarFromTarget;
|
||||||
bWasLeftFootPlantingChanged = bIsLeftFootPlanted;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +164,7 @@ UAnimSequence* UOLSBaseLinkedLayerAnimInstance::SelectStartCycleAnimation(const
|
|||||||
|
|
||||||
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_ForwardFacing.StartCycle.
|
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_ForwardFacing.StartCycle.
|
||||||
GetMovementAnimationByAngle(
|
GetMovementAnimationByAngle(
|
||||||
velocityDirection, angle, bIsRightFootPlanted);
|
velocityDirection, angle, bIsRightFootFarFromTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
UAnimSequence* UOLSBaseLinkedLayerAnimInstance::SelectCycleAnimation(const bool isCrouching,
|
UAnimSequence* UOLSBaseLinkedLayerAnimInstance::SelectCycleAnimation(const bool isCrouching,
|
||||||
@ -181,21 +187,16 @@ UAnimSequence* UOLSBaseLinkedLayerAnimInstance::SelectPivotAnimation(const bool
|
|||||||
const EOLSGait gait,
|
const EOLSGait gait,
|
||||||
const EOLSCardinalDirection velocityDirection,
|
const EOLSCardinalDirection velocityDirection,
|
||||||
const EOLSHipDirection hipDirection,
|
const EOLSHipDirection hipDirection,
|
||||||
const float angle,
|
const float angle) const
|
||||||
float& outPivotTime) const
|
|
||||||
{
|
{
|
||||||
if (isAiming)
|
if (isAiming)
|
||||||
{
|
{
|
||||||
outPivotTime = 0.2f;
|
|
||||||
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_CameraFacing.GetPivotFromHipDirection(hipDirection).
|
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_CameraFacing.GetPivotFromHipDirection(hipDirection).
|
||||||
GetMovementAnimationByCardinalDirection(velocityDirection);
|
GetMovementAnimationByCardinalDirection(velocityDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (bUseFeetFlagsForPivot)
|
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_ForwardFacing.Pivot.GetLeftOrRightByAngle(
|
||||||
? GetGaitAnimSets(isCrouching, gait).GaitAnimSet_ForwardFacing.Pivot.GetLeftOrRightAnim(
|
angle, bIsLeftFootFarFromTarget, bIsRightFootFarFromTarget);
|
||||||
angle, bIsLeftFootPlanted, bIsRightFootPlanted, outPivotTime)
|
|
||||||
: GetGaitAnimSets(isCrouching, gait).GaitAnimSet_ForwardFacing.Pivot.GetLeftOrRightAnim(
|
|
||||||
angle, FeetPositionCurve, outPivotTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UAnimSequence* UOLSBaseLinkedLayerAnimInstance::SelectStopCycleAnimation(const bool isCrouching,
|
UAnimSequence* UOLSBaseLinkedLayerAnimInstance::SelectStopCycleAnimation(const bool isCrouching,
|
||||||
@ -211,7 +212,7 @@ UAnimSequence* UOLSBaseLinkedLayerAnimInstance::SelectStopCycleAnimation(const b
|
|||||||
GetMovementAnimationByCardinalDirection(velocityDirection);
|
GetMovementAnimationByCardinalDirection(velocityDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_ForwardFacing.Stop.GetLeftOrRightStopAnim(FeetPositionCurve);
|
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_ForwardFacing.StopCycle.GetLeftOrRightAnim(bIsRightFootFarFromTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
FVector2D UOLSBaseLinkedLayerAnimInstance::SelectPlayRateByLocomotionState(
|
FVector2D UOLSBaseLinkedLayerAnimInstance::SelectPlayRateByLocomotionState(
|
||||||
@ -300,7 +301,7 @@ void UOLSBaseLinkedLayerAnimInstance::ProcessTurnInPlaceTransitionLogic(const fl
|
|||||||
|
|
||||||
bool UOLSBaseLinkedLayerAnimInstance::ShouldSelectNewPivotAnimation(const float lastPivotTime) const
|
bool UOLSBaseLinkedLayerAnimInstance::ShouldSelectNewPivotAnimation(const float lastPivotTime) const
|
||||||
{
|
{
|
||||||
return ShouldLookingOrAimingDirectionSelectNewPivotAnimation(lastPivotTime) || ShouldVelocityDirectionSelectNewPivotAnimation(lastPivotTime);
|
return ShouldLookingOrAimingDirectionSelectNewPivotAnimation(lastPivotTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UOLSBaseLinkedLayerAnimInstance::ShouldLookingOrAimingDirectionSelectNewPivotAnimation(const float lastPivotTime) const
|
bool UOLSBaseLinkedLayerAnimInstance::ShouldLookingOrAimingDirectionSelectNewPivotAnimation(const float lastPivotTime) const
|
||||||
@ -308,11 +309,6 @@ bool UOLSBaseLinkedLayerAnimInstance::ShouldLookingOrAimingDirectionSelectNewPiv
|
|||||||
return (bIsLookingOrAimingDirection && lastPivotTime > 0.0f);
|
return (bIsLookingOrAimingDirection && lastPivotTime > 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UOLSBaseLinkedLayerAnimInstance::ShouldVelocityDirectionSelectNewPivotAnimation(const float lastPivotTime) const
|
|
||||||
{
|
|
||||||
return (bIsLookingOrAimingDirection && lastPivotTime > 0.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
UOLSBaseLayerAnimInstance* UOLSBaseLinkedLayerAnimInstance::GetBaseMainAnimInstance() const
|
UOLSBaseLayerAnimInstance* UOLSBaseLinkedLayerAnimInstance::GetBaseMainAnimInstance() const
|
||||||
{
|
{
|
||||||
return BaseMainAnimInstance;
|
return BaseMainAnimInstance;
|
||||||
|
|||||||
@ -82,8 +82,7 @@ protected:
|
|||||||
const EOLSGait gait,
|
const EOLSGait gait,
|
||||||
const EOLSCardinalDirection velocityDirection,
|
const EOLSCardinalDirection velocityDirection,
|
||||||
const EOLSHipDirection hipDirection,
|
const EOLSHipDirection hipDirection,
|
||||||
const float angle,
|
const float angle) const;
|
||||||
float& outPivotTime) const;
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, meta = (BlueprintThreadSafe), Category = "ThreadSafe|Selectors")
|
UFUNCTION(BlueprintCallable, meta = (BlueprintThreadSafe), Category = "ThreadSafe|Selectors")
|
||||||
class UAnimSequence* SelectStopCycleAnimation(const bool isCrouching,
|
class UAnimSequence* SelectStopCycleAnimation(const bool isCrouching,
|
||||||
@ -121,9 +120,6 @@ protected:
|
|||||||
UFUNCTION(BlueprintCallable, meta = (BlueprintThreadSafe), Category = "ThreadSafe|Pivot")
|
UFUNCTION(BlueprintCallable, meta = (BlueprintThreadSafe), Category = "ThreadSafe|Pivot")
|
||||||
bool ShouldLookingOrAimingDirectionSelectNewPivotAnimation(const float lastPivotTime) const;
|
bool ShouldLookingOrAimingDirectionSelectNewPivotAnimation(const float lastPivotTime) const;
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, meta = (BlueprintThreadSafe), Category = "ThreadSafe|Pivot")
|
|
||||||
bool ShouldVelocityDirectionSelectNewPivotAnimation(const float lastPivotTime) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, meta = (BlueprintThreadSafe))
|
UFUNCTION(BlueprintCallable, meta = (BlueprintThreadSafe))
|
||||||
@ -203,23 +199,16 @@ protected:
|
|||||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|OrientationWarping")
|
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|OrientationWarping")
|
||||||
float OrientationWarpingAlpha = 0.f;
|
float OrientationWarpingAlpha = 0.f;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|FeetPosition")
|
|
||||||
float FeetPositionCurve = 0.0f;
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|FeetPosition")
|
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|FeetPosition")
|
||||||
uint8 bWasRightFootPlantingChanged : 1 = false;
|
uint8 bWasRightFootPlantingChanged : 1 = false;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|FeetPosition")
|
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|FeetPosition")
|
||||||
uint8 bWasLeftFootPlantingChanged : 1 = false;
|
uint8 bIsRightFootFarFromTarget : 1 = true;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|FeetPosition")
|
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|FeetPosition")
|
||||||
uint8 bIsRightFootPlanted : 1 = true;
|
uint8 bIsLeftFootFarFromTarget : 1 = true;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|FeetPosition")
|
|
||||||
uint8 bIsLeftFootPlanted : 1 = true;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -232,9 +221,6 @@ protected:
|
|||||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|Pivots")
|
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|Pivots")
|
||||||
float TimeAtPivotStop = 0.f;
|
float TimeAtPivotStop = 0.f;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|Pivots")
|
|
||||||
float PivotTime = 0.f;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadOnly , Category = "ThreadSafe|IdleBreaks")
|
UPROPERTY(BlueprintReadOnly , Category = "ThreadSafe|IdleBreaks")
|
||||||
@ -276,37 +262,8 @@ protected:
|
|||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Settings|AnimSet|DistanceMatching")
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Settings|AnimSet|DistanceMatching")
|
||||||
FName JumpDistanceCurveName = NAME_None;
|
FName JumpDistanceCurveName = NAME_None;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Settings|AnimSet|FeetPosition")
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Settings|FeetPosition")
|
||||||
FName FeetPositionCurveName = NAME_None;
|
FOLSFeetPositionSettings FeetPositionSettings;
|
||||||
/**
|
|
||||||
* Threshold value to determine if a foot is considered planted on the ground.
|
|
||||||
* Range: 0.0 to 1.0, where:
|
|
||||||
* - Values closer to 0 make foot planting detection more sensitive
|
|
||||||
* - Values closer to 1 require more definitive foot contact
|
|
||||||
* Default value of 0.4 provides a balanced detection for most animations
|
|
||||||
*/
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Settings|AnimSet|FeetPosition",
|
|
||||||
meta = (ClampMin = "0.0", ClampMax = "1.0", UIMin = "0.0", UIMax = "1.0"))
|
|
||||||
float FootPlantedThreshold = 0.4f;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines the method used for selecting pivot animations based on foot positioning.
|
|
||||||
*
|
|
||||||
* When true:
|
|
||||||
* - Uses explicit foot planting flags (isLeftFootPlanted, isRightFootPlanted)
|
|
||||||
* - More precise control over pivot selection
|
|
||||||
* - Better for complex animation transitions
|
|
||||||
*
|
|
||||||
* When false:
|
|
||||||
* - Uses simplified feet position value
|
|
||||||
* - Relies on animation curves for foot position
|
|
||||||
* - More suitable for basic movement patterns
|
|
||||||
*
|
|
||||||
* @note This affects how pivot animations are chosen in FOLSMovementAnimSets_ForwardFacing_Pivot
|
|
||||||
* @see FOLSMovementAnimSets_ForwardFacing_Pivot::GetLeftOrRightAnim
|
|
||||||
*/
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Settings|AnimSet|FeetPosition")
|
|
||||||
uint8 bUseFeetFlagsForPivot : 1 = true;
|
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Settings|StrideWarping")
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Settings|StrideWarping")
|
||||||
float StrideWarpingBlendInDurationScaled = .2f;
|
float StrideWarpingBlendInDurationScaled = .2f;
|
||||||
|
|||||||
@ -9,6 +9,26 @@
|
|||||||
#include "UObject/Object.h"
|
#include "UObject/Object.h"
|
||||||
#include "OLSAnimationData.generated.h"
|
#include "OLSAnimationData.generated.h"
|
||||||
|
|
||||||
|
USTRUCT(BlueprintType)
|
||||||
|
struct FOLSFeetPositionSettings
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "FeetPositionSettings")
|
||||||
|
FName IKFootRight = NAME_None;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "FeetPositionSettings")
|
||||||
|
FName IKTargetFootRight = NAME_None;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "FeetPositionSettings")
|
||||||
|
FName IKFootLeft = NAME_None;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "FeetPositionSettings")
|
||||||
|
FName IKTargetFootLeft = NAME_None;
|
||||||
|
};
|
||||||
|
|
||||||
USTRUCT(BlueprintType)
|
USTRUCT(BlueprintType)
|
||||||
struct FOLSRotationMatchingData
|
struct FOLSRotationMatchingData
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user