Some improvements for Pivot
This commit is contained in:
parent
4f3b97f455
commit
532271aa75
Binary file not shown.
Binary file not shown.
@ -1,13 +1,13 @@
|
|||||||
/Engine=C:/Program Files/Epic Games/UE_5.5/Engine/Shaders
|
/Engine=C:/Program Files/Epic Games/UE_5.5/Engine/Shaders
|
||||||
/ShaderAutogen=H:/Projects/OLS/Intermediate/ShaderAutogen
|
/ShaderAutogen=H:/Projects/OLS/Intermediate/ShaderAutogen
|
||||||
/Plugin/ComputeFramework=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/Runtime/ComputeFramework/Shaders
|
|
||||||
/Plugin/Runtime/HairStrands=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/Runtime/HairStrands/Shaders
|
|
||||||
/Plugin/FX/Niagara=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/FX/Niagara/Shaders
|
/Plugin/FX/Niagara=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/FX/Niagara/Shaders
|
||||||
|
/NNEDenoiserShaders=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/NNE/NNEDenoiser/Shaders
|
||||||
/Plugin/GLTFExporter=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/Enterprise/GLTFExporter/Shaders
|
/Plugin/GLTFExporter=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/Enterprise/GLTFExporter/Shaders
|
||||||
/NFORDenoise=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/Experimental/NFORDenoise/Shaders
|
/NFORDenoise=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/Experimental/NFORDenoise/Shaders
|
||||||
/Plugin/ExrReaderShaders=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/Media/ImgMedia/Shaders
|
/Plugin/ExrReaderShaders=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/Media/ImgMedia/Shaders
|
||||||
/Plugin/WmfMedia=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/Media/WmfMedia/Shaders
|
/Plugin/WmfMedia=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/Media/WmfMedia/Shaders
|
||||||
/NNEDenoiserShaders=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/NNE/NNEDenoiser/Shaders
|
/Plugin/ComputeFramework=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/Runtime/ComputeFramework/Shaders
|
||||||
|
/Plugin/Runtime/HairStrands=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/Runtime/HairStrands/Shaders
|
||||||
/Plugin/HoldoutComposite=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/Experimental/Compositing/HoldoutComposite/Shaders
|
/Plugin/HoldoutComposite=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/Experimental/Compositing/HoldoutComposite/Shaders
|
||||||
/Plugin/Optimus=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/Animation/DeformerGraph/Shaders
|
/Plugin/Optimus=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/Animation/DeformerGraph/Shaders
|
||||||
/Plugin/Experimental/ChaosNiagara=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/Experimental/ChaosNiagara/Shaders
|
/Plugin/Experimental/ChaosNiagara=C:/Program Files/Epic Games/UE_5.5/Engine/Plugins/Experimental/ChaosNiagara/Shaders
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
Binary file not shown.
Binary file not shown.
@ -71,6 +71,7 @@ void UOLSBaseLayerAnimInstance::NativeBeginPlay()
|
|||||||
if (LocomotionComponent)
|
if (LocomotionComponent)
|
||||||
{
|
{
|
||||||
DesiredGait = LocomotionComponent->GetDesiredGait();
|
DesiredGait = LocomotionComponent->GetDesiredGait();
|
||||||
|
DesiredMaxSpeed = LocomotionComponent->GetMaxSpeedByGait(DesiredGait);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -82,6 +83,8 @@ void UOLSBaseLayerAnimInstance::NativeBeginPlay()
|
|||||||
PrevGait = prevGait;
|
PrevGait = prevGait;
|
||||||
Gait = LocomotionComponent->GetGait();
|
Gait = LocomotionComponent->GetGait();
|
||||||
bHasGaitChanged = true;
|
bHasGaitChanged = true;
|
||||||
|
|
||||||
|
DesiredMaxSpeed = LocomotionComponent->GetMaxSpeedByGait(Gait);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -172,6 +175,10 @@ void UOLSBaseLayerAnimInstance::NativeUpdateVelocityData(const TScriptInterface<
|
|||||||
void UOLSBaseLayerAnimInstance::NativeUpdateAccelerationData(APawn* owningPawn, const float deltaSeconds)
|
void UOLSBaseLayerAnimInstance::NativeUpdateAccelerationData(APawn* owningPawn, const float deltaSeconds)
|
||||||
{
|
{
|
||||||
OwningPawnAcceleration = MoveableInterface->GetCurrentAcceleration();
|
OwningPawnAcceleration = MoveableInterface->GetCurrentAcceleration();
|
||||||
|
|
||||||
|
InputAmount = FMath::GetMappedRangeValueClamped(FVector2D(0.f, MoveableInterface->GetMaxAcceleration()),
|
||||||
|
FVector2D(0.f, 1.f),
|
||||||
|
MoveableInterface->GetCurrentAcceleration().Size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void UOLSBaseLayerAnimInstance::NativeUpdateCharacterStateData(
|
void UOLSBaseLayerAnimInstance::NativeUpdateCharacterStateData(
|
||||||
@ -293,7 +300,9 @@ void UOLSBaseLayerAnimInstance::NativeThreadSafeUpdateAccelerationData(const flo
|
|||||||
OwningPawnAcceleration.GetSafeNormal2D(), WorldRotation);
|
OwningPawnAcceleration.GetSafeNormal2D(), WorldRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LocalAcceleration2D.GetSafeNormal2D().Dot(LocalVelocity2D.GetSafeNormal2D()) < -.2f && HasAcceleration() && !bIsPivoting)
|
const float desiredMaxSpeed = DesiredMaxSpeed * InputAmount;
|
||||||
|
if (LocalAcceleration2D.GetSafeNormal2D().Dot(LocalVelocity2D.GetSafeNormal2D()) < -.2f && WorldVelocity.Size2D() >
|
||||||
|
desiredMaxSpeed * 0.5f && HasAcceleration() && !bIsPivoting)
|
||||||
{
|
{
|
||||||
bIsPivoting = true;
|
bIsPivoting = true;
|
||||||
}
|
}
|
||||||
@ -353,6 +362,9 @@ void UOLSBaseLayerAnimInstance::NativeThreadSafeUpdateCharacterStateData(const f
|
|||||||
TimeSinceFiredWeapon = (bGameplayTag_IsFiring) ? 0.f : TimeSinceFiredWeapon + deltaSeconds;
|
TimeSinceFiredWeapon = (bGameplayTag_IsFiring) ? 0.f : TimeSinceFiredWeapon + deltaSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool wasPivotingLastUpdate = bWasPivoting;
|
||||||
|
bWasPivoting = (bIsPivoting != wasPivotingLastUpdate);
|
||||||
|
|
||||||
// In air state.
|
// In air state.
|
||||||
{
|
{
|
||||||
bIsJumping = false;
|
bIsJumping = false;
|
||||||
|
@ -202,6 +202,16 @@ void UOLSLocomotionComponent::SetRotationMode(EOLSRotationMode newRotationMode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float UOLSLocomotionComponent::GetMaxSpeedByGait(const EOLSGait gait) const
|
||||||
|
{
|
||||||
|
return Gaits.FindChecked(gait);
|
||||||
|
}
|
||||||
|
|
||||||
|
const float& UOLSLocomotionComponent::GetMovementInputAmount() const
|
||||||
|
{
|
||||||
|
return MovementInputAmount;
|
||||||
|
}
|
||||||
|
|
||||||
void UOLSLocomotionComponent::SetDesiredGait(const EOLSGait newGait, const bool shouldForce /* = false */)
|
void UOLSLocomotionComponent::SetDesiredGait(const EOLSGait newGait, const bool shouldForce /* = false */)
|
||||||
{
|
{
|
||||||
if (shouldForce || DesiredGait != newGait)
|
if (shouldForce || DesiredGait != newGait)
|
||||||
|
@ -481,6 +481,22 @@ FVector UOLSLocomotionBPLibrary::PredictGroundMovementPivotLocation(const FVecto
|
|||||||
|
|
||||||
return predictedPivotLocation;
|
return predictedPivotLocation;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
// float UOLSLocomotionBPLibrary::RotationMatching(const float deltaTime, const float interpSpeed,
|
||||||
|
// const float animRotAlpha, const FVector& acceleration,
|
||||||
|
// const float targetAngle,
|
||||||
|
// FOLSRotationMatchingData& outRotationMatchingData,
|
||||||
|
// float& outTargetRotationYaw)
|
||||||
|
// {
|
||||||
|
// const float animDesiredRotation = FRotator::NormalizeAxis(targetAngle * animRotAlpha);
|
||||||
|
// const float currentAccelDir = acceleration.GetSafeNormal2D().Rotation().Yaw;
|
||||||
|
//
|
||||||
|
// outRotationMatchingData.CurrentAccelDir = FRotator::NormalizeAxis()
|
||||||
|
// const float desiredRotationChange = FRotator::NormalizeAxis(FMath::RInterpTo(
|
||||||
|
// FRotator{0.0f, 0.f, 0.0f},
|
||||||
|
// FRotator{0.0f, AnimDesiredRotation, 0.0f},
|
||||||
|
// DeltaTime, InterpSpeed).Yaw);
|
||||||
|
// }
|
||||||
|
|
||||||
EOLSCardinalDirection UOLSLocomotionBPLibrary::SelectCardinalDirectionFromAngle(float angle,
|
EOLSCardinalDirection UOLSLocomotionBPLibrary::SelectCardinalDirectionFromAngle(float angle,
|
||||||
float deadZone,
|
float deadZone,
|
||||||
|
@ -254,6 +254,9 @@ protected:
|
|||||||
UPROPERTY(BlueprintReadOnly, Category = "ThreadSafe|AccelerationData")
|
UPROPERTY(BlueprintReadOnly, Category = "ThreadSafe|AccelerationData")
|
||||||
uint8 bIsPivoting : 1;
|
uint8 bIsPivoting : 1;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadOnly, Category = "ThreadSafe|AccelerationData")
|
||||||
|
uint8 bWasPivoting : 1;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadOnly, Category = "ThreadSafe|AccelerationData")
|
UPROPERTY(BlueprintReadOnly, Category = "ThreadSafe|AccelerationData")
|
||||||
FVector PivotDirection2D = FVector::ZeroVector;
|
FVector PivotDirection2D = FVector::ZeroVector;
|
||||||
|
|
||||||
@ -382,6 +385,12 @@ protected:
|
|||||||
TObjectPtr<class UAnimInstance> LastLinkedLayer = nullptr;
|
TObjectPtr<class UAnimInstance> LastLinkedLayer = nullptr;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|LocomotionComponentData")
|
||||||
|
float DesiredMaxSpeed = 0.f;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|LocomotionComponentData")
|
||||||
|
float InputAmount = 0.f;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|LocomotionComponentData")
|
UPROPERTY(BlueprintReadWrite, Category = "ThreadSafe|LocomotionComponentData")
|
||||||
EOLSGait DesiredGait = EOLSGait::EWalk;
|
EOLSGait DesiredGait = EOLSGait::EWalk;
|
||||||
|
@ -66,6 +66,12 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable, Category = "OLSLocomotionComponent")
|
UFUNCTION(BlueprintCallable, Category = "OLSLocomotionComponent")
|
||||||
void SetRotationMode(EOLSRotationMode newRotationMode, bool shouldForce = false);
|
void SetRotationMode(EOLSRotationMode newRotationMode, bool shouldForce = false);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "OLSLocomotionComponent")
|
||||||
|
float GetMaxSpeedByGait(const EOLSGait gait) const;
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "OLSLocomotionComponent")
|
||||||
|
const float& GetMovementInputAmount() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "OLSLocomotionComponent")
|
UFUNCTION(BlueprintCallable, Category = "OLSLocomotionComponent")
|
||||||
|
@ -9,6 +9,32 @@
|
|||||||
#include "UObject/Object.h"
|
#include "UObject/Object.h"
|
||||||
#include "OLSAnimationData.generated.h"
|
#include "OLSAnimationData.generated.h"
|
||||||
|
|
||||||
|
USTRUCT(BlueprintType)
|
||||||
|
struct FOLSRotationMatchingData
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, Category = "RotationMatchingData")
|
||||||
|
float TargetAngle = 0.0f;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, Category = "RotationMatchingData")
|
||||||
|
float CurrentAccelDir = 0.0f;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, Category = "RotationMatchingData")
|
||||||
|
float EntryAccelDir = 0.0f;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, Category = "RotationMatchingData")
|
||||||
|
float EntryRotYaw = 0.0f;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, Category = "RotationMatchingData")
|
||||||
|
float DesiredYaw = 0.0f;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, Category = "RotationMatchingData")
|
||||||
|
uint8 AnimHasRotationLeft : 1 = true;
|
||||||
|
};
|
||||||
|
|
||||||
USTRUCT(BlueprintType)
|
USTRUCT(BlueprintType)
|
||||||
struct FOLSTurnInPlaceAnimSet
|
struct FOLSTurnInPlaceAnimSet
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "SequenceEvaluatorLibrary.h"
|
#include "SequenceEvaluatorLibrary.h"
|
||||||
|
#include "Data/OLSAnimationData.h"
|
||||||
#include "Data/OLSEnumLibrary.h"
|
#include "Data/OLSEnumLibrary.h"
|
||||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||||
#include "OLSLocomotionBPLibrary.generated.h"
|
#include "OLSLocomotionBPLibrary.generated.h"
|
||||||
@ -29,6 +30,7 @@ public: // ~ Helpers ~ //
|
|||||||
* @note This function is useful for identifying key moments in animations where directional changes occur,
|
* @note This function is useful for identifying key moments in animations where directional changes occur,
|
||||||
* such as during character turns or sharp movements, ensuring smooth transitions or special handling.
|
* such as during character turns or sharp movements, ensuring smooth transitions or special handling.
|
||||||
*/
|
*/
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "OLS|Function Library", meta=(BlueprintThreadSafe))
|
||||||
static float FindPivotTime(const UAnimSequenceBase* animSequence, const float sampleRate);
|
static float FindPivotTime(const UAnimSequenceBase* animSequence, const float sampleRate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,7 +56,8 @@ public: // ~ Helpers ~ //
|
|||||||
* @return The interpolated time at which the curve reaches the specified value. Returns 0 if the curve is invalid or the value cannot be found.
|
* @return The interpolated time at which the curve reaches the specified value. Returns 0 if the curve is invalid or the value cannot be found.
|
||||||
*
|
*
|
||||||
* @note This function uses binary search to efficiently locate the curve value and linearly interpolates between keyframes for precision.
|
* @note This function uses binary search to efficiently locate the curve value and linearly interpolates between keyframes for precision.
|
||||||
*/
|
*/
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "OLS|Function Library", meta=(BlueprintThreadSafe))
|
||||||
static float GetTimeAtCurveValue(const UAnimSequenceBase* animSequence, const float& curveValue, FName curveName);
|
static float GetTimeAtCurveValue(const UAnimSequenceBase* animSequence, const float& curveValue, FName curveName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -178,6 +181,12 @@ public:
|
|||||||
static FVector PredictGroundMovementPivotLocation(const FVector& acceleration, const FVector& velocity,
|
static FVector PredictGroundMovementPivotLocation(const FVector& acceleration, const FVector& velocity,
|
||||||
float groundFriction);
|
float groundFriction);
|
||||||
|
|
||||||
|
// UFUNCTION(BlueprintCallable,Category = "OLS|Function Library",meta=(BlueprintThreadSafe))
|
||||||
|
// static float RotationMatching(const float deltaTime, const float interpSpeed, const float animRotAlpha,
|
||||||
|
// const FVector& acceleration, const float targetAngle, UPARAM(ref) FOLSRotationMatchingData& outRotationMatchingData,
|
||||||
|
// UPARAM(ref) float& outTargetRotationYaw);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable,BlueprintPure,Category = "OLS|Function Library",meta=(BlueprintThreadSafe))
|
UFUNCTION(BlueprintCallable,BlueprintPure,Category = "OLS|Function Library",meta=(BlueprintThreadSafe))
|
||||||
|
Loading…
Reference in New Issue
Block a user