Added utility function to get pawn 2d speed

master
MostExcellent 2024-10-22 11:43:10 -07:00
parent 56dc78db07
commit 54e9efd1e0
3 changed files with 16 additions and 1 deletions

View File

@ -6,8 +6,10 @@
#include "Kismet/BlueprintFunctionLibrary.h"
#include "VRGASUtils.generated.h"
class UGameplayAbility;
class UGameplayEffect;
class UAbilitySystemComponent;
/**
*
*/

View File

@ -2,6 +2,7 @@
#include "VRUtilsBPLibrary.h"
#include "VRUtils.h"
#include "GameFramework/PawnMovementComponent.h"
float UVRUtilsBPLibrary::GetPawnSpeedAlongVector(const APawn* InPawn, const FVector& InVector)
{
@ -44,6 +45,15 @@ float UVRUtilsBPLibrary::GetPawnUpVectorSpeed(const APawn* InPawn)
return FVector::DotProduct(Velocity, UpVector);
}
float UVRUtilsBPLibrary::GetPawnXYSpeed(const APawn* InPawn)
{
if (!InPawn) return 0.0f;
const FVector PawnVelocity = InPawn->GetMovementComponent()->Velocity;
return PawnVelocity.Size2D();
}
float UVRUtilsBPLibrary::GetDegreeDiff(const FVector& A, const FVector& B)
{
const float DotResult = FVector::DotProduct(A, B);

View File

@ -27,12 +27,15 @@ public:
UFUNCTION(BlueprintPure, Category = "VRUtils|Movement|Speed")
static float GetPawnForwardVectorSpeed(const APawn* InPawn);
UFUNCTION(BlueprintPure, Category = "VRUtils|Movement|Speed")
static float GetPawnRightVectorSpeed(const APawn* InPawn);
UFUNCTION(BlueprintPure, Category = "VRUtils|Movement|Speed")
static float GetPawnUpVectorSpeed(const APawn* InPawn);
UFUNCTION(BlueprintPure, Category = "VRUtils|Movement|Speed")
static float GetPawnXYSpeed(const APawn* InPawn);
#pragma endregion
#pragma region Math