5#include "Net/UnrealNetwork.h"
9 : Super(ObjectInitializer)
11 this->SetGenerateOverlapEvents(
true);
12 this->PrimaryComponentTick.bStartWithTickEnabled =
false;
13 PrimaryComponentTick.bCanEverTick =
true;
70 this->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap);
79void UVRSliderComponent::GetLifetimeReplicatedProps(TArray< class FLifetimeProperty > & OutLifetimeProps)
const
81 Super::GetLifetimeReplicatedProps(OutLifetimeProps);
94 Super::PreReplication(ChangedPropertyTracker);
113 if (USplineComponent * ParentSpline = Cast<USplineComponent>(GetAttachParent()))
136 Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
160 this->SetComponentTickEnabled(
false);
179 if (newProgress < 0.0f || FMath::IsNearlyEqual(newProgress, 0.0f, 0.00001f))
193 else if (newProgress > 1.0f || FMath::IsNearlyEqual(newProgress, 1.0f, 0.00001f))
223 FVector CurLoc = ClampedLocation;
226 (FMath::Abs(
MinSlideDistance.X) > 0.0f && CurLoc.X <= -FMath::Abs(this->MinSlideDistance.X)) ||
239 if (newProgress < 0.0f || FMath::IsNearlyEqual(newProgress, 0.0f, 0.00001f))
244 else if (newProgress > 1.0f || FMath::IsNearlyEqual(newProgress, 1.0f, 0.00001f))
259 this->SetComponentTickEnabled(
false);
290 FVector CurInteractorLocation = CurrentRelativeTransform.InverseTransformPosition(GrippingController->
GetPivotLocation());
297 FVector WorldCalculatedLocation = CurrentRelativeTransform.TransformPosition(CalculatedLocation);
314 WorldCalculatedLocation =
SplineComponentToFollow->GetLocationAtSplineInputKey(ClosestKey, ESplineCoordinateSpace::World);
317 bool bLerpToNewKey =
true;
318 bool bChangedLocation =
false;
321 FMath::Abs((FMath::TruncToFloat(ClosestKey) - FMath::TruncToFloat(
LastInputKey))) > 1.0f &&
325 bLerpToNewKey =
false;
339 bChangedLocation =
true;
341 else if (bLerpToNewKey)
343 trans =
SplineComponentToFollow->FindTransformClosestToWorldLocation(WorldCalculatedLocation, ESplineCoordinateSpace::World,
true);
344 bChangedLocation =
true;
347 if (bChangedLocation)
350 trans = trans * ParentTransform.Inverse();
351 this->SetRelativeTransform(trans);
356 FVector WorldLocation;
361 bChangedLocation =
true;
363 else if (bLerpToNewKey)
365 WorldLocation =
SplineComponentToFollow->FindLocationClosestToWorldLocation(WorldCalculatedLocation, ESplineCoordinateSpace::World);
366 bChangedLocation =
true;
369 if (bChangedLocation)
370 this->SetRelativeLocation(ParentTransform.InverseTransformPosition(WorldLocation));
428 uint8 GripID = GripInformation.
GripID;
483 FTransform ReversedRelativeTransform = FTransform(GripInformation.
RelativeTransform.ToInverseMatrixWithScale());
484 FTransform RelativeToGripTransform = ReversedRelativeTransform * this->GetComponentTransform();
506 SetComponentTickEnabled(
true);
519 this->SetComponentTickEnabled(
true);
525 float TotalDistance = Len.Size();
540 this->SetComponentTickEnabled(
false);
625 GripStiffnessOut = 0.0f;
626 GripDampingOut = 0.0f;
651 if (OverridePrefix.IsNone())
652 bSecondarySlot ? OverridePrefix =
"VRGripS" : OverridePrefix =
"VRGripP";
664 CurHoldingControllers.Empty();
724 FVector fScaleFactor = FVector(1.0f);
732 FVector Progress = (ValueToClamp - (-MinScale)) / Dist;
742 Progress.X = FMath::Clamp(Progress.X, 0.f, 1.f);
743 Progress.Y = FMath::Clamp(Progress.Y, 0.f, 1.f);
744 Progress.Z = FMath::Clamp(Progress.Z, 0.f, 1.f);
747 return (Progress * Dist) - (MinScale);
756 if ((InKey >= 0) && (InKey < NumSegments))
759 const int32 ReparamNextIndex = ReparamPrevIndex + 1;
761 const float Alpha = (InKey *
SplineComponentToFollow->ReparamStepsPerSegment) -
static_cast<float>(ReparamPrevIndex);
767 return FMath::Lerp(PrevDistance, NextDistance, Alpha);
769 else if (InKey >= NumSegments)
782 float ClosestKey = CurKey;
799 float Progress = 0.f;
846 if (SplineToFollow !=
nullptr)
867 FTransform WorldTransform =
SplineComponentToFollow->FindTransformClosestToWorldLocation(this->GetComponentLocation(), ESplineCoordinateSpace::World,
true);
871 WorldTransform = WorldTransform * ParentTransform.Inverse();
872 this->SetRelativeTransform(WorldTransform);
876 this->SetWorldLocation(WorldTransform.GetLocation());
885 NewSliderProgress = FMath::Clamp(NewSliderProgress, 0.0f, 1.0f);
894 FTransform trans =
SplineComponentToFollow->GetTransformAtDistanceAlongSpline(splineProgress, ESplineCoordinateSpace::World,
true);
896 trans = trans * ParentTransform.Inverse();
897 this->SetRelativeTransform(trans);
901 this->SetRelativeLocation(ParentTransform.InverseTransformPosition(
SplineComponentToFollow->GetLocationAtDistanceAlongSpline(splineProgress, ESplineCoordinateSpace::World)));
933 FVector CalculatedLocation = CurrentRelativeTransform.InverseTransformPosition(this->GetComponentLocation());
EGripMovementReplicationSettings
UENUM(Blueprintable)
@ ForceClientSideMovement
@ ForceServerSideMovement
ESecondaryGripType
UENUM(Blueprintable)
EGripCollisionType
UENUM(Blueprintable)
EGripLateUpdateSettings
UENUM(Blueprintable)
EGripInterfaceTeleportBehavior
UENUM(Blueprintable)
UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = MotionController)
bool HasGripAuthority(const FBPActorGripInformation &Grip)
FORCEINLINE FVector GetPivotLocation()
void GetGripByID(FBPActorGripInformation &Grip, uint8 IDToLookForGrip, EBPVRResultSwitch &Result)
UFUNCTION(BlueprintCallable, Category = "GripMotionController", meta = (ExpandEnumAsExecs = "Result")...
FVRGripControllerOnGripOutOfRange OnGripOutOfRange
UPROPERTY(BlueprintAssignable, Category = "GripMotionController")
bool DropObjectByInterface(UObject *ObjectToDrop=nullptr, uint8 GripIDToDrop=0, FVector OptionalAngularVelocity=FVector::ZeroVector, FVector OptionalLinearVelocity=FVector::ZeroVector)
UFUNCTION(BlueprintCallable, Category = "GripMotionController")
static void GetGripSlotInRangeByTypeName_Component(FName SlotType, USceneComponent *Component, FVector WorldLocation, float MaxRange, bool &bHadSlotInRange, FTransform &SlotWorldTransform, FName &SlotName, UGripMotionControllerComponent *QueryController=nullptr)
UFUNCTION(BlueprintPure, Category = "VRGrip", meta = (bIgnoreSelf = "true", DisplayName = "GetGripSlo...
static float Interactible_GetThresholdSnappedValue(float ValueToSnap, float SnapIncrement, float SnapThreshold)
UFUNCTION(BlueprintPure, Category = "VRInteractibleFunctions", meta = (bIgnoreSelf = "true"))
static FTransform Interactible_GetCurrentParentTransform(USceneComponent *SceneComponentToCheck)
UFUNCTION(BlueprintPure, Category = "VRInteractibleFunctions", meta = (bIgnoreSelf = "true"))
UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = (VRExpansionPlugin))
float SnapThreshold
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent", meta = (editcondition = "...
void OnGrip_Implementation(UGripMotionControllerComponent *GrippingController, const FBPActorGripInformation &GripInformation) override
FBPGripPair HoldingGrip
UPROPERTY(BlueprintReadOnly, Category = "VRGripInterface")
void ClosestGripSlotInRange_Implementation(FVector WorldLocation, bool bSecondarySlot, bool &bHadSlotInRange, FTransform &SlotWorldTransform, FName &SlotName, UGripMotionControllerComponent *CallingController=nullptr, FName OverridePrefix=NAME_None) override
FVector InitialDropLocation
FVRSliderFinishedLerpingSignature OnSliderFinishedLerping
UPROPERTY(BlueprintAssignable, Category = "VRSliderComponent")
FGameplayTagContainer GameplayTags
UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "GameplayTags")
EGripMovementReplicationSettings GripMovementReplicationType_Implementation() override
UVRSliderComponent(const FObjectInitializer &ObjectInitializer)
EGripLateUpdateSettings GripLateUpdateSetting_Implementation() override
float PrimarySlotRange
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GripSettings")
float BreakDistance
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRGripInterface")
virtual void Native_NotifyThrowGripDelegates(UGripMotionControllerComponent *Controller, bool bGripped, const FBPActorGripInformation &GripInformation, bool bWasSocketed=false) override
void OnSecondaryUsed_Implementation() override
float SplineLastSliderProgress
float LastSliderProgressState
int FramesToAverage
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent|Momentum Settings",...
float SnapIncrement
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent", meta = (editcondition = "...
void SetHeld_Implementation(UGripMotionControllerComponent *NewHoldingController, uint8 GripID, bool bNewIsHeld) override
EVRInteractibleSliderLerpType SplineLerpType
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent")
void OnEndUsed_Implementation() override
float GetCurrentSliderProgress(FVector CurLocation, bool bUseKeyInstead=false, float CurKey=0.f)
float SplineMomentumAtDrop
int GripPriority
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GripSettings")
float MaxSliderMomentum
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent|Momentum Settings",...
bool CheckAutoDrop(UGripMotionControllerComponent *GrippingController, const FBPActorGripInformation &GripInformation)
float SecondarySlotRange
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GripSettings")
USplineComponent * SplineComponentToFollow
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Replicated, Category = "VRSliderComponent")
EGripInterfaceTeleportBehavior TeleportBehavior_Implementation() override
virtual void PreReplication(IRepChangedPropertyTracker &ChangedPropertyTracker) override
bool bIsLocked
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent")
bool bEnforceSplineLinearity
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent")
float EventThrowThreshold
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent", meta = (ClampMin = "0....
bool bRepGameplayTags
UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface")
void GetGripStiffnessAndDamping_Implementation(float &GripStiffnessOut, float &GripDampingOut) override
bool bIsHeld
UPROPERTY(BlueprintReadOnly, Category = "VRGripInterface", meta = (ScriptName = "IsCurrentlyHeld"))
void ReceiveSliderHitPoint(float SliderProgressPoint)
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "Slider State Changed"))
FVector MinSlideDistance
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent")
float CurrentSliderProgress
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "VRSliderComponent")
EGripMovementReplicationSettings MovementReplicationSetting
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRGripInterface")
virtual void OnRegister() override
bool SimulateOnDrop_Implementation() override
void OnSecondaryGrip_Implementation(UGripMotionControllerComponent *GripOwningController, USceneComponent *SecondaryGripComponent, const FBPActorGripInformation &GripInformation) override
float SliderMomentumFriction
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent|Momentum Settings",...
bool bDenyGripping
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRGripInterface", meta = (ScriptName = "IsDen...
void OnChildGripRelease_Implementation(UGripMotionControllerComponent *ReleasingController, const FBPActorGripInformation &GripInformation, bool bWasSocketed=false) override
bool RequestsSocketing_Implementation(USceneComponent *&ParentToSocketTo, FName &OptionalSocketName, FTransform_NetQuantize &RelativeTransform) override
bool bUpdateInTick
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent")
void OnEndSecondaryUsed_Implementation() override
void GetLerpedKey(float &ClosestKey, float DeltaTime)
bool GetGripScripts_Implementation(TArray< UVRGripScriptBase * > &ArrayReference) override
void IsHeld_Implementation(TArray< FBPGripPair > &CurHoldingControllers, bool &bCurIsHeld) override
void OnGripRelease_Implementation(UGripMotionControllerComponent *ReleasingController, const FBPActorGripInformation &GripInformation, bool bWasSocketed=false) override
EVRInteractibleSliderDropBehavior SliderBehaviorWhenReleased
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent")
void SetIsLocked(bool bNewLockedState)
UFUNCTION(BlueprintCallable, Category = "GripSettings")
FVROnGripSignature OnGripped
UPROPERTY(BlueprintAssignable, Category = "Grip Events")
bool bIsLerping
UPROPERTY(BlueprintReadOnly, Category = "VRSliderComponent")
void SetSplineComponentToFollow(USplineComponent *SplineToFollow)
UFUNCTION(BlueprintCallable, Category = "VRSliderComponent")
FVector InitialInteractorLocation
bool bSliderUsesSnapPoints
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent")
ESecondaryGripType SecondaryGripType_Implementation() override
FTransform_NetQuantize InitialRelativeTransform
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_InitialRelativeTransform, Category = "VRSliderCo...
bool bOriginalReplicatesMovement
bool bUseLegacyLogic
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent")
FVRSliderHitPointSignature OnSliderHitPoint
UPROPERTY(BlueprintAssignable, Category = "VRSliderComponent")
void SetSliderProgress(float NewSliderProgress)
UFUNCTION(BlueprintCallable, Category = "VRSliderComponent")
void OnUsed_Implementation() override
void TickGrip_Implementation(UGripMotionControllerComponent *GrippingController, const FBPActorGripInformation &GripInformation, float DeltaTime) override
bool bIncrementProgressBetweenSnapPoints
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent", meta = (editcondition = "...
float CalculateSliderProgress()
UFUNCTION(BlueprintCallable, Category = "VRSliderComponent")
bool bSlideDistanceIsInParentSpace
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent")
FVector MaxSlideDistance
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent")
void SetGripPriority(int NewGripPriority)
UFUNCTION(BlueprintCallable, Category = "GripSettings")
bool bReplicateMovement
UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface|Replication")
void OnSecondaryGripRelease_Implementation(UGripMotionControllerComponent *GripOwningController, USceneComponent *ReleasingSecondaryGripComponent, const FBPActorGripInformation &GripInformation) override
void ReceiveSliderFinishedLerping(float FinalProgress)
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "Slider Finished Lerping"))
float GetDistanceAlongSplineAtSplineInputKey(float InKey) const
float GripBreakDistance_Implementation() override
void CheckSliderProgress()
void ResetToParentSplineLocation()
virtual void BeginPlay() override
FVROnDropSignature OnDropped
UPROPERTY(BlueprintAssignable, Category = "Grip Events")
float SplineLerpValue
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent", meta = (ClampMin = "0",...
float SliderRestitution
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent|Momentum Settings",...
bool bAutoDropWhenLocked
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent")
EGripCollisionType GetPrimaryGripType_Implementation(bool bIsSlot) override
void ResetInitialSliderLocation()
UFUNCTION(BlueprintCallable, Category = "VRSliderComponent")
bool bFollowSplineRotationAndScale
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRSliderComponent")
void OnChildGrip_Implementation(UGripMotionControllerComponent *GrippingController, const FBPActorGripInformation &GripInformation) override
FVector ClampSlideVector(FVector ValueToClamp)
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override
FVector LastSliderProgress
bool AllowsMultipleGrips_Implementation() override
bool DenyGripping_Implementation(UGripMotionControllerComponent *GripInitiator=nullptr) override
void OnInput_Implementation(FKey Key, EInputEvent KeyEvent) override
FBPAdvGripSettings AdvancedGripSettings_Implementation() override
USTRUCT(BlueprintType, Category = "VRExpansionLibrary")
USTRUCT(BlueprintType, Category = "VRExpansionLibrary")
UGripMotionControllerComponent * HoldingController
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GripPair")
uint8 GripID
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GripPair")