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 "KismetAnimationLibrary.h"
|
||||
#include "AnimInstances/OLSBaseLayerAnimInstance.h"
|
||||
|
||||
void UOLSBaseLinkedLayerAnimInstance::NativeInitializeAnimation()
|
||||
@ -58,27 +59,32 @@ void UOLSBaseLinkedLayerAnimInstance::NativeThreadSafeUpdateSkeletonControlData(
|
||||
{
|
||||
OrientationWarpingAlpha = GetCurveValue(EnableOrientationWarpingName);
|
||||
|
||||
FeetPositionCurve = GetCurveValue(FeetPositionCurveName);
|
||||
bIsRightFootPlanted = FeetPositionCurve > FootPlantedThreshold;
|
||||
bIsLeftFootPlanted = FMath::Abs(FeetPositionCurve) > FootPlantedThreshold;
|
||||
bIsLeftFootFarFromTarget = UKismetAnimationLibrary::K2_DistanceBetweenTwoSocketsAndMapRange(
|
||||
GetOwningComponent(), FeetPositionSettings.IKFootLeft, RTS_World,
|
||||
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 (!bIsRightFootPlanted && !bIsLeftFootPlanted)
|
||||
if (!bIsRightFootFarFromTarget && !bIsLeftFootFarFromTarget)
|
||||
{
|
||||
if (bWasRightFootPlantingChanged)
|
||||
{
|
||||
bIsRightFootPlanted = true;
|
||||
bIsRightFootFarFromTarget = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bIsLeftFootPlanted = true;
|
||||
bIsLeftFootFarFromTarget = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update the last valid foot
|
||||
bWasRightFootPlantingChanged = bIsRightFootPlanted;
|
||||
bWasLeftFootPlantingChanged = bIsLeftFootPlanted;
|
||||
bWasRightFootPlantingChanged = bIsRightFootFarFromTarget;
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,7 +164,7 @@ UAnimSequence* UOLSBaseLinkedLayerAnimInstance::SelectStartCycleAnimation(const
|
||||
|
||||
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_ForwardFacing.StartCycle.
|
||||
GetMovementAnimationByAngle(
|
||||
velocityDirection, angle, bIsRightFootPlanted);
|
||||
velocityDirection, angle, bIsRightFootFarFromTarget);
|
||||
}
|
||||
|
||||
UAnimSequence* UOLSBaseLinkedLayerAnimInstance::SelectCycleAnimation(const bool isCrouching,
|
||||
@ -181,21 +187,16 @@ UAnimSequence* UOLSBaseLinkedLayerAnimInstance::SelectPivotAnimation(const bool
|
||||
const EOLSGait gait,
|
||||
const EOLSCardinalDirection velocityDirection,
|
||||
const EOLSHipDirection hipDirection,
|
||||
const float angle,
|
||||
float& outPivotTime) const
|
||||
const float angle) const
|
||||
{
|
||||
if (isAiming)
|
||||
{
|
||||
outPivotTime = 0.2f;
|
||||
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_CameraFacing.GetPivotFromHipDirection(hipDirection).
|
||||
GetMovementAnimationByCardinalDirection(velocityDirection);
|
||||
}
|
||||
|
||||
return (bUseFeetFlagsForPivot)
|
||||
? GetGaitAnimSets(isCrouching, gait).GaitAnimSet_ForwardFacing.Pivot.GetLeftOrRightAnim(
|
||||
angle, bIsLeftFootPlanted, bIsRightFootPlanted, outPivotTime)
|
||||
: GetGaitAnimSets(isCrouching, gait).GaitAnimSet_ForwardFacing.Pivot.GetLeftOrRightAnim(
|
||||
angle, FeetPositionCurve, outPivotTime);
|
||||
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_ForwardFacing.Pivot.GetLeftOrRightByAngle(
|
||||
angle, bIsLeftFootFarFromTarget, bIsRightFootFarFromTarget);
|
||||
}
|
||||
|
||||
UAnimSequence* UOLSBaseLinkedLayerAnimInstance::SelectStopCycleAnimation(const bool isCrouching,
|
||||
@ -211,7 +212,7 @@ UAnimSequence* UOLSBaseLinkedLayerAnimInstance::SelectStopCycleAnimation(const b
|
||||
GetMovementAnimationByCardinalDirection(velocityDirection);
|
||||
}
|
||||
|
||||
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_ForwardFacing.Stop.GetLeftOrRightStopAnim(FeetPositionCurve);
|
||||
return GetGaitAnimSets(isCrouching, gait).GaitAnimSet_ForwardFacing.StopCycle.GetLeftOrRightAnim(bIsRightFootFarFromTarget);
|
||||
}
|
||||
|
||||
FVector2D UOLSBaseLinkedLayerAnimInstance::SelectPlayRateByLocomotionState(
|
||||
@ -300,7 +301,7 @@ void UOLSBaseLinkedLayerAnimInstance::ProcessTurnInPlaceTransitionLogic(const fl
|
||||
|
||||
bool UOLSBaseLinkedLayerAnimInstance::ShouldSelectNewPivotAnimation(const float lastPivotTime) const
|
||||
{
|
||||
return ShouldLookingOrAimingDirectionSelectNewPivotAnimation(lastPivotTime) || ShouldVelocityDirectionSelectNewPivotAnimation(lastPivotTime);
|
||||
return ShouldLookingOrAimingDirectionSelectNewPivotAnimation(lastPivotTime);
|
||||
}
|
||||
|
||||
bool UOLSBaseLinkedLayerAnimInstance::ShouldLookingOrAimingDirectionSelectNewPivotAnimation(const float lastPivotTime) const
|
||||
@ -308,11 +309,6 @@ bool UOLSBaseLinkedLayerAnimInstance::ShouldLookingOrAimingDirectionSelectNewPiv
|
||||
return (bIsLookingOrAimingDirection && lastPivotTime > 0.0f);
|
||||
}
|
||||
|
||||
bool UOLSBaseLinkedLayerAnimInstance::ShouldVelocityDirectionSelectNewPivotAnimation(const float lastPivotTime) const
|
||||
{
|
||||
return (bIsLookingOrAimingDirection && lastPivotTime > 0.0f);
|
||||
}
|
||||
|
||||
UOLSBaseLayerAnimInstance* UOLSBaseLinkedLayerAnimInstance::GetBaseMainAnimInstance() const
|
||||
{
|
||||
return BaseMainAnimInstance;
|
||||
|
||||
@ -82,8 +82,7 @@ protected:
|
||||
const EOLSGait gait,
|
||||
const EOLSCardinalDirection velocityDirection,
|
||||
const EOLSHipDirection hipDirection,
|
||||
const float angle,
|
||||
float& outPivotTime) const;
|
||||
const float angle) const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (BlueprintThreadSafe), Category = "ThreadSafe|Selectors")
|
||||
class UAnimSequence* SelectStopCycleAnimation(const bool isCrouching,
|
||||
@ -121,9 +120,6 @@ protected:
|
||||
UFUNCTION(BlueprintCallable, meta = (BlueprintThreadSafe), Category = "ThreadSafe|Pivot")
|
||||
bool ShouldLookingOrAimingDirectionSelectNewPivotAnimation(const float lastPivotTime) const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (BlueprintThreadSafe), Category = "ThreadSafe|Pivot")
|
||||
bool ShouldVelocityDirectionSelectNewPivotAnimation(const float lastPivotTime) const;
|
||||
|
||||
protected:
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (BlueprintThreadSafe))
|
||||
@ -203,23 +199,16 @@ protected:
|
||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|OrientationWarping")
|
||||
float OrientationWarpingAlpha = 0.f;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|FeetPosition")
|
||||
float FeetPositionCurve = 0.0f;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|FeetPosition")
|
||||
uint8 bWasRightFootPlantingChanged : 1 = false;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|FeetPosition")
|
||||
uint8 bWasLeftFootPlantingChanged : 1 = false;
|
||||
uint8 bIsRightFootFarFromTarget : 1 = true;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|FeetPosition")
|
||||
uint8 bIsRightFootPlanted : 1 = true;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|SkeletonControl|FeetPosition")
|
||||
uint8 bIsLeftFootPlanted : 1 = true;
|
||||
uint8 bIsLeftFootFarFromTarget : 1 = true;
|
||||
|
||||
protected:
|
||||
|
||||
@ -231,9 +220,6 @@ protected:
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|Pivots")
|
||||
float TimeAtPivotStop = 0.f;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|Pivots")
|
||||
float PivotTime = 0.f;
|
||||
|
||||
protected:
|
||||
|
||||
@ -276,38 +262,9 @@ protected:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Settings|AnimSet|DistanceMatching")
|
||||
FName JumpDistanceCurveName = NAME_None;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Settings|AnimSet|FeetPosition")
|
||||
FName FeetPositionCurveName = NAME_None;
|
||||
/**
|
||||
* 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;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Settings|FeetPosition")
|
||||
FOLSFeetPositionSettings FeetPositionSettings;
|
||||
|
||||
/**
|
||||
* 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")
|
||||
float StrideWarpingBlendInDurationScaled = .2f;
|
||||
|
||||
|
||||
@ -9,6 +9,26 @@
|
||||
#include "UObject/Object.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)
|
||||
struct FOLSRotationMatchingData
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user