Compare commits
3 Commits
d0cae51cca
...
56dc78db07
| Author | SHA1 | Date |
|---|---|---|
|
|
56dc78db07 | |
|
|
780062a8ed | |
|
|
8313c57825 |
|
|
@ -2,17 +2,6 @@
|
||||||
# Visual Studio 2015 user specific files
|
# Visual Studio 2015 user specific files
|
||||||
.vs/
|
.vs/
|
||||||
|
|
||||||
#Jetbrains IDE files
|
|
||||||
.idea/
|
|
||||||
.fleet/
|
|
||||||
*.DotSettings
|
|
||||||
|
|
||||||
# VS Code files
|
|
||||||
.vscode/
|
|
||||||
*.code-workspace
|
|
||||||
|
|
||||||
# Linux Makefile
|
|
||||||
Makefile
|
|
||||||
|
|
||||||
# Compiled Object files
|
# Compiled Object files
|
||||||
*.slo
|
*.slo
|
||||||
|
|
@ -86,3 +75,30 @@ Plugins/*/Intermediate/*
|
||||||
# Cache files for the editor to use
|
# Cache files for the editor to use
|
||||||
DerivedDataCache/*
|
DerivedDataCache/*
|
||||||
|
|
||||||
|
# Visual Studio 2015+ user-specific files
|
||||||
|
.vs/
|
||||||
|
.vsconfig
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.VC.opendb
|
||||||
|
|
||||||
|
# Don't ignore whitelist PakBlacklist-<BuildConfiguration>.txt files
|
||||||
|
!Build/*/
|
||||||
|
Build/*/**
|
||||||
|
!Build/*/PakBlacklist*.txt
|
||||||
|
|
||||||
|
# Don't ignore icon files in Build
|
||||||
|
!Build/**/*.ico
|
||||||
|
|
||||||
|
|
||||||
|
#Files Ignored
|
||||||
|
Makefile.bin
|
||||||
|
Makefile
|
||||||
|
*.directory
|
||||||
|
.idea/*
|
||||||
|
.vscode/*
|
||||||
|
*.code-workspace
|
||||||
|
*.opendb
|
||||||
|
*.DotSettings
|
||||||
|
.fleet/
|
||||||
|
Cooked/*
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
[/Script/EngineSettings.GeneralProjectSettings]
|
[/Script/EngineSettings.GeneralProjectSettings]
|
||||||
ProjectID=B0DD2F214F0AC320FA72EB9C9432375E
|
ProjectID=B0DD2F214F0AC320FA72EB9C9432375E
|
||||||
CopyrightNotice=Copyright Vagabond Rose Interactive, all rights reserved
|
CopyrightNotice=Copyright
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
// Copyright
|
||||||
|
|
||||||
|
|
||||||
|
#include "AbilitySystem/StartupData/VRStartupAbilitySystemData.h"
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
// Copyright
|
||||||
|
|
||||||
|
|
||||||
|
#include "AbilitySystem/VRAbilitySystemComponent.h"
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
// Copyright
|
||||||
|
|
||||||
|
|
||||||
|
#include "Input/VRInputComponent.h"
|
||||||
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
// Copyright
|
||||||
|
|
||||||
|
|
||||||
|
#include "Input/VRInputConfig.h"
|
||||||
|
|
||||||
|
#include "Logging.h"
|
||||||
|
|
||||||
|
UInputAction* UVRInputConfig::FindNativeInputActionForTag(const FGameplayTag& InTag, bool bLogNotFound) const
|
||||||
|
{
|
||||||
|
if (!InTag.IsValid()) return nullptr;
|
||||||
|
|
||||||
|
for (const FVRTagInputBinding& Action : NativeInputActions)
|
||||||
|
{
|
||||||
|
if (!Action.IsValid()) continue;
|
||||||
|
|
||||||
|
if (Action.InputAction && Action.InputTag.IsValid())
|
||||||
|
{
|
||||||
|
return Action.InputAction.Get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bLogNotFound)
|
||||||
|
{
|
||||||
|
UE_LOG(VRGAS_Log, Error, TEXT("Could not find Native Action for Tag %s on InputConfig %s"),
|
||||||
|
*InTag.ToString(), *GetNameSafe(this))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
UInputAction* UVRInputConfig::FindAbilityInputActionForTag(const FGameplayTag& InTag, bool bLogNotFound) const
|
||||||
|
{
|
||||||
|
if (!InTag.IsValid()) return nullptr;
|
||||||
|
|
||||||
|
for (const FVRTagInputBinding& Action : AbilityInputActions)
|
||||||
|
{
|
||||||
|
if (!Action.IsValid() && Action.InputTag.IsValid())
|
||||||
|
{
|
||||||
|
return Action.InputAction.Get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bLogNotFound)
|
||||||
|
{
|
||||||
|
// TODO: Add logging for VRGAS
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
#include "Logging.h"
|
||||||
|
|
||||||
|
DEFINE_LOG_CATEGORY(VRGAS_Log)
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
|
||||||
|
DECLARE_LOG_CATEGORY_EXTERN(VRGAS_Log, Log, All)
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
// Copyright
|
||||||
|
|
||||||
|
|
||||||
|
#include "Player/VRPlayerController.h"
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
#include "VRGASTypes.h"
|
||||||
|
|
||||||
|
#include "Abilities/GameplayAbility.h"
|
||||||
|
|
||||||
|
bool FVRAbilitySet::IsValid() const
|
||||||
|
{
|
||||||
|
return AbilityClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FVRAbilitySet::IsValidInput() const
|
||||||
|
{
|
||||||
|
return InputTag.IsValid() && AbilityClass;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
// Copyright
|
||||||
|
|
||||||
|
|
||||||
|
#include "VRGASUtils.h"
|
||||||
|
|
||||||
|
#include "AbilitySystemComponent.h"
|
||||||
|
#include "AbilitySystemGlobals.h"
|
||||||
|
#include "GameplayAbilitySpec.h"
|
||||||
|
#include "Abilities/GameplayAbility.h"
|
||||||
|
|
||||||
|
void UVRGASUtils::BatchGrantAbilities(const TArray<TSubclassOf<UGameplayAbility>>& InAbilitiesToGrant, UAbilitySystemComponent* InAbilitySystemComponent, int32 ApplyLevel, bool bDebugLog)
|
||||||
|
{
|
||||||
|
if (InAbilitiesToGrant.IsEmpty()) return;
|
||||||
|
|
||||||
|
for (const TSubclassOf<UGameplayAbility>& Ability : InAbilitiesToGrant)
|
||||||
|
{
|
||||||
|
if (!Ability) continue;
|
||||||
|
|
||||||
|
FGameplayAbilitySpec AbilitySpec(Ability);
|
||||||
|
AbilitySpec.SourceObject = InAbilitySystemComponent->GetAvatarActor();
|
||||||
|
AbilitySpec.Level = ApplyLevel;
|
||||||
|
|
||||||
|
InAbilitySystemComponent->GiveAbility(AbilitySpec);
|
||||||
|
|
||||||
|
if (bDebugLog)
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("UWarriorUtils::BatchGrantAbilities - Successfully Granted ability %s"), *AbilitySpec.Handle.ToString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UVRGASUtils::ApplyEffectToTarget(AActor* Target, TSubclassOf<UGameplayEffect> GameplayEffectClass, UObject* SourceObject, float Level)
|
||||||
|
{
|
||||||
|
// Get the Ability System Component of the target
|
||||||
|
// We set LookForComponent to true in case someone didn't implement the Ability System Interface
|
||||||
|
UAbilitySystemComponent* TargetASC = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Target, true);
|
||||||
|
|
||||||
|
if (!TargetASC)
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("ApplyEffectToTarget: Target Actor does not have an Ability System Component"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GameplayEffectClass)
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Error, TEXT("ApplyEffectToTarget: GameplayEffectClass is null"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ApplyEffectToTargetASC(TargetASC, GameplayEffectClass, SourceObject, Level);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UVRGASUtils::ApplyEffectToTargetASC(UAbilitySystemComponent* Target, TSubclassOf<UGameplayEffect> GameplayEffectClass, UObject* SourceObject, float Level)
|
||||||
|
{
|
||||||
|
check(Target);
|
||||||
|
check(GameplayEffectClass);
|
||||||
|
|
||||||
|
FGameplayEffectContextHandle EffectContextHandle = Target->MakeEffectContext();
|
||||||
|
EffectContextHandle.AddSourceObject(SourceObject);
|
||||||
|
|
||||||
|
const FGameplayEffectSpecHandle EffectSpec = Target->MakeOutgoingSpec(GameplayEffectClass, Level, EffectContextHandle);
|
||||||
|
const FActiveGameplayEffectHandle ActiveGameplayEffectHandle = Target->ApplyGameplayEffectSpecToSelf(*EffectSpec.Data.Get());
|
||||||
|
// return if application was successful
|
||||||
|
return ActiveGameplayEffectHandle.WasSuccessfullyApplied();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
// Copyright
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "GameplayEffect.h"
|
||||||
|
#include "Engine/DataAsset.h"
|
||||||
|
#include "VRStartupAbilitySystemData.generated.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct FVRAbilitySet;
|
||||||
|
class UGameplayAbility;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class VRGAS_API UVRStartupAbilitySystemData : public UDataAsset
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Starup Data|Abilities")
|
||||||
|
TArray<UGameplayAbility> StartupAbilities;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Starup Data|Abilities")
|
||||||
|
TArray<FVRAbilitySet> StartupAbilitySets;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, Category = "Startup Data|Attributes")
|
||||||
|
UGameplayEffect AttributeInitEffect;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, Category = "Startup Data|Attributes")
|
||||||
|
float AttributeInitLevel = 1.f;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Copyright
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "AbilitySystemComponent.h"
|
||||||
|
#include "VRAbilitySystemComponent.generated.h"
|
||||||
|
|
||||||
|
DECLARE_MULTICAST_DELEGATE_OneParam(FEffectAssetTags, const FGameplayTagContainer& /*AssetTags*/);
|
||||||
|
DECLARE_MULTICAST_DELEGATE(FAbilitiesGiven);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class VRGAS_API UVRAbilitySystemComponent : public UAbilitySystemComponent
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
void AbilityActorInfoSet();
|
||||||
|
|
||||||
|
FEffectAssetTags EffectAssetTags;
|
||||||
|
FAbilitiesGiven OnAbilitiesGiven;
|
||||||
|
|
||||||
|
bool bStartupAbilitiesGiven = false;
|
||||||
|
|
||||||
|
// Add startup abilities
|
||||||
|
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
// Copyright
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "EnhancedInputComponent.h"
|
||||||
|
#include "VRInputConfig.h"
|
||||||
|
#include "VRInputComponent.generated.h"
|
||||||
|
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class VRGAS_API UVRInputComponent : public UEnhancedInputComponent
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
template <class UserClass, typename FuncType>
|
||||||
|
void BindNativeActions(const UVRInputConfig* InputConfig, const FGameplayTag& InputTag, ETriggerEvent TriggerEvent,
|
||||||
|
UserClass* Object,FuncType Func, bool bLogNotFound = true);
|
||||||
|
|
||||||
|
template <class UserClass, typename PressedFuncType, typename ReleasedFuncType>
|
||||||
|
void BindAbilityActions(const UVRInputConfig* InputConfig, UserClass* Object, PressedFuncType PressedFunc, ReleasedFuncType ReleasedFunc);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class UserClass, typename FuncType>
|
||||||
|
void UVRInputComponent::BindNativeActions(const UVRInputConfig* InputConfig, const FGameplayTag& InputTag, ETriggerEvent TriggerEvent,
|
||||||
|
UserClass* Object,FuncType Func, const bool bLogNotFound)
|
||||||
|
{
|
||||||
|
check(InputConfig)
|
||||||
|
if (UInputAction* Action = InputConfig->FindNativeInputActionForTag(InputTag, bLogNotFound))
|
||||||
|
{
|
||||||
|
BindAction(Action, TriggerEvent, Object, Func);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class UserClass, typename PressedFuncType, typename ReleasedFuncType>
|
||||||
|
void UVRInputComponent::BindAbilityActions(const UVRInputConfig* InputConfig, UserClass* Object, PressedFuncType PressedFunc, ReleasedFuncType ReleasedFunc);
|
||||||
|
{
|
||||||
|
check(InputConfig)
|
||||||
|
for (const FVRTagInputBinding& Binding : InputConfig->AbilityInputActions)
|
||||||
|
{
|
||||||
|
if (Binding.IsValid())
|
||||||
|
{
|
||||||
|
if (PressedFunc) BindAction(Binding.InputAction, ETriggerEvent::Started, Object, PressedFunc, Binding.InputTag);
|
||||||
|
|
||||||
|
if (ReleasedFunc) BindAction(Binding.InputAction, ETriggerEvent::Completed, Object, ReleasedFunc, Binding.InputTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
// Copyright
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "GameplayTagContainer.h"
|
||||||
|
#include "Engine/DataAsset.h"
|
||||||
|
#include "VRInputConfig.generated.h"
|
||||||
|
|
||||||
|
|
||||||
|
class UInputAction;
|
||||||
|
|
||||||
|
USTRUCT(BlueprintType)
|
||||||
|
struct FVRTagInputBinding
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
|
||||||
|
TObjectPtr<UInputAction> InputAction = nullptr;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Meta = (Categories = "InputTag"))
|
||||||
|
FGameplayTag InputTag;
|
||||||
|
|
||||||
|
bool IsValid() const
|
||||||
|
{
|
||||||
|
return InputTag.IsValid() && InputAction != nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS(BlueprintType, Const) // Const for now, since we aren't doing anything beyond what lyra does here
|
||||||
|
class VRGAS_API UVRInputConfig : public UDataAsset
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Meta = (TitleProperty = "InputAction"))
|
||||||
|
TArray<FVRTagInputBinding> NativeInputActions;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Meta = (TitleProperty = "InputAction"))
|
||||||
|
TArray<FVRTagInputBinding> AbilityInputActions;
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||||
|
UInputAction* FindNativeInputActionForTag(const FGameplayTag& InTag, bool bLogNotFound = true) const;
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||||
|
UInputAction* FindAbilityInputActionForTag(const FGameplayTag& InTag, bool bLogNotFound = true) const;
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
// Copyright
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "GameFramework/PlayerController.h"
|
||||||
|
#include "VRPlayerController.generated.h"
|
||||||
|
|
||||||
|
class UVRInputConfig;
|
||||||
|
class UInputMappingContext;
|
||||||
|
class UAbilitySystemComponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class VRGAS_API AVRPlayerController : public APlayerController
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
AVRPlayerController();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// TODO: Implement controller
|
||||||
|
virtual void SetupInputComponent() override;
|
||||||
|
virtual void OnPossess(APawn* InPawn) override;
|
||||||
|
|
||||||
|
#pragma region InputConfig
|
||||||
|
UPROPERTY(EditDefaultsOnly, Category = Input)
|
||||||
|
TObjectPtr<UInputMappingContext> InputMappingContext;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, Category = Input)
|
||||||
|
TObjectPtr<UVRInputConfig> InputConfig;
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region GAS
|
||||||
|
UPROPERTY()
|
||||||
|
TWeakObjectPtr<UAbilitySystemComponent> CachedAbilitySystemComponent;
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintPure, Category = "Ability System", meta = (HideSelfPin))
|
||||||
|
UAbilitySystemComponent* GetAbilitySystemComponent();
|
||||||
|
#pragma endregion
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "GameplayTagContainer.h"
|
||||||
|
|
||||||
|
class UGameplayAbility;
|
||||||
|
|
||||||
|
USTRUCT(BlueprintType)
|
||||||
|
struct FVRAbilitySet
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, meta = (Categories = "InputTag"))
|
||||||
|
FGameplayTag InputTag;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
|
||||||
|
TSubclassOf<UGameplayAbility> AbilityClass;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
|
||||||
|
uint32 AbilityLevel = 1.f;
|
||||||
|
|
||||||
|
bool IsValid() const;
|
||||||
|
|
||||||
|
bool IsValidInput() const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
// Copyright
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||||
|
#include "VRGASUtils.generated.h"
|
||||||
|
|
||||||
|
class UGameplayEffect;
|
||||||
|
class UAbilitySystemComponent;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class VRGAS_API UVRGASUtils : public UBlueprintFunctionLibrary
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Utils|Ability System")
|
||||||
|
static void BatchGrantAbilities(const TArray<TSubclassOf<UGameplayAbility>>& InAbilitiesToGrant,
|
||||||
|
UAbilitySystemComponent* InAbilitySystemComponent,
|
||||||
|
int32 ApplyLevel, bool bDebugLog = false);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Utils|Ability System")
|
||||||
|
static bool ApplyEffectToTarget(AActor* Target, TSubclassOf<UGameplayEffect> GameplayEffectClass, UObject* SourceObject, float Level = 1.f);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Utils|Ability System")
|
||||||
|
static bool ApplyEffectToTargetASC(UAbilitySystemComponent* Target, TSubclassOf<UGameplayEffect> GameplayEffectClass, UObject* SourceObject, float Level = 1.f);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
@ -1,10 +1,51 @@
|
||||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
// Copyright
|
||||||
|
|
||||||
#include "VRUtilsBPLibrary.h"
|
#include "VRUtilsBPLibrary.h"
|
||||||
#include "VRUtils.h"
|
#include "VRUtils.h"
|
||||||
|
|
||||||
UVRUtilsBPLibrary::UVRUtilsBPLibrary(const FObjectInitializer& ObjectInitializer)
|
float UVRUtilsBPLibrary::GetPawnSpeedAlongVector(const APawn* InPawn, const FVector& InVector)
|
||||||
: Super(ObjectInitializer)
|
|
||||||
{
|
{
|
||||||
|
if (!InPawn) return 0.0f;
|
||||||
|
|
||||||
|
const FVector Velocity = InPawn->GetVelocity();
|
||||||
|
const FVector InVectorNormalized = InVector.GetSafeNormal();
|
||||||
|
|
||||||
|
return FVector::DotProduct(Velocity, InVectorNormalized);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The following speed functions do not use GetPawnSpeedAlongVector to avoid one extra copy
|
||||||
|
float UVRUtilsBPLibrary::GetPawnForwardVectorSpeed(const APawn* InPawn)
|
||||||
|
{
|
||||||
|
if (!InPawn) return 0.0f;
|
||||||
|
|
||||||
|
const FVector Velocity = InPawn->GetVelocity();
|
||||||
|
const FVector ForwardVector = InPawn->GetActorForwardVector();
|
||||||
|
|
||||||
|
return FVector::DotProduct(Velocity, ForwardVector);
|
||||||
|
}
|
||||||
|
|
||||||
|
float UVRUtilsBPLibrary::GetPawnRightVectorSpeed(const APawn* InPawn)
|
||||||
|
{
|
||||||
|
if (!InPawn) return 0.0f;
|
||||||
|
|
||||||
|
const FVector Velocity = InPawn->GetVelocity();
|
||||||
|
const FVector RightVector = InPawn->GetActorRightVector();
|
||||||
|
|
||||||
|
return FVector::DotProduct(Velocity, RightVector);
|
||||||
|
}
|
||||||
|
|
||||||
|
float UVRUtilsBPLibrary::GetPawnUpVectorSpeed(const APawn* InPawn)
|
||||||
|
{
|
||||||
|
if (!InPawn) return 0.0f;
|
||||||
|
|
||||||
|
const FVector Velocity = InPawn->GetVelocity();
|
||||||
|
const FVector UpVector = InPawn->GetActorUpVector();
|
||||||
|
|
||||||
|
return FVector::DotProduct(Velocity, UpVector);
|
||||||
|
}
|
||||||
|
|
||||||
|
float UVRUtilsBPLibrary::GetDegreeDiff(const FVector& A, const FVector& B)
|
||||||
|
{
|
||||||
|
const float DotResult = FVector::DotProduct(A, B);
|
||||||
|
return FMath::RadiansToDegrees(FMath::Acos(DotResult));
|
||||||
}
|
}
|
||||||
|
|
@ -1,30 +1,49 @@
|
||||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
// Copyright
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||||
#include "VRUtilsBPLibrary.generated.h"
|
#include "VRUtilsBPLibrary.generated.h"
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Function library class.
|
* Vagabond Rose core utility functions, exposed to blueprints.
|
||||||
* Each function in it is expected to be static and represents blueprint node that can be called in any blueprint.
|
*/
|
||||||
*
|
|
||||||
* When declaring function you can define metadata for the node. Key function specifiers will be BlueprintPure and BlueprintCallable.
|
|
||||||
* BlueprintPure - means the function does not affect the owning object in any way and thus creates a node without Exec pins.
|
|
||||||
* BlueprintCallable - makes a function which can be executed in Blueprints - Thus it has Exec pins.
|
|
||||||
* DisplayName - full name of the node, shown when you mouse over the node and in the blueprint drop down menu.
|
|
||||||
* Its lets you name the node using characters not allowed in C++ function names.
|
|
||||||
* CompactNodeTitle - the word(s) that appear on the node.
|
|
||||||
* Keywords - the list of keywords that helps you to find node when you search for it using Blueprint drop-down menu.
|
|
||||||
* Good example is "Print String" node which you can find also by using keyword "log".
|
|
||||||
* Category - the category your node will be under in the Blueprint drop-down menu.
|
|
||||||
*
|
|
||||||
* For more info on custom blueprint nodes visit documentation:
|
|
||||||
* https://wiki.unrealengine.com/Custom_Blueprint_Node_Creation
|
|
||||||
*/
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class UVRUtilsBPLibrary : public UBlueprintFunctionLibrary
|
class UVRUtilsBPLibrary : public UBlueprintFunctionLibrary
|
||||||
{
|
{
|
||||||
GENERATED_UCLASS_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
#pragma region MovementSpeeds
|
||||||
|
/**
|
||||||
|
* Computes the pawn's speed along a given vector.
|
||||||
|
*
|
||||||
|
* @param InPawn The pawn whose speed is being measured. If null, the function returns 0.
|
||||||
|
* @param InVector The vector along which the speed is to be measured.
|
||||||
|
* @return The speed of the pawn along the provided vector.
|
||||||
|
*/
|
||||||
|
UFUNCTION(BlueprintPure, Category = "VRUtils|Movement|Speed")
|
||||||
|
static float GetPawnSpeedAlongVector(const APawn* InPawn, UPARAM(ref) const FVector& InVector);
|
||||||
|
|
||||||
|
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);
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Math
|
||||||
|
/**
|
||||||
|
* Calculates the angular difference in degrees between two vectors.
|
||||||
|
*
|
||||||
|
* @param A The first vector.
|
||||||
|
* @param B The second vector.
|
||||||
|
* @return The angular difference between the two vectors in degrees.
|
||||||
|
*/
|
||||||
|
UFUNCTION(BlueprintPure, Category = "VRUtils|Math")
|
||||||
|
static float GetDegreeDiff(const FVector& A, const FVector& B);
|
||||||
|
#pragma endregion
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,10 @@
|
||||||
"Editor"
|
"Editor"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Name": "GameplayAbilities",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"Name": "VRGAS",
|
"Name": "VRGAS",
|
||||||
"Enabled": true
|
"Enabled": true
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue