5#include "Net/UnrealNetwork.h"
9 : Super(ObjectInitializer)
11 this->SetGenerateOverlapEvents(
true);
12 this->PrimaryComponentTick.bStartWithTickEnabled =
false;
13 PrimaryComponentTick.bCanEverTick =
true;
43 this->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap);
52void UVRMountComponent::GetLifetimeReplicatedProps(TArray< class FLifetimeProperty > & OutLifetimeProps)
const
54 Super::GetLifetimeReplicatedProps(OutLifetimeProps);
63 Super::PreReplication(ChangedPropertyTracker);
88 Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
94 Super::OnUnregister();
102 FVector CurInteractorLocation = CurrentRelativeTransform.InverseTransformPosition(GrippingController->
GetPivotLocation());
109 FVector MountToTarget;
114 CurInteractorLocation = CurInteractorLocation *-1;
118 FRotator RelativeRot = GetRelativeRotation();
122 CurInteractorLocation = (CurInteractorLocation.GetSafeNormal() *
InitialInteractorLocation.Size() + CurToForwardAxisVec).GetSafeNormal()*CurInteractorLocation.Size();
190 MountToTarget = CurInteractorLocation.GetSafeNormal();
196 MountToTarget = CurInteractorLocation.GetSafeNormal();
203 Rot = MountToTarget.Rotation();
209 FQuat::FindBetweenVectors(FVector(0, 0, 1), CurInteractorLocation.GetSafeNormal()).ToAxisAndAngle(nAxis, FlipAngle);
212 if (FlipAngle < FlipingZone || FlipAngle > PI -
FlipingZone)
223 EntryUpVec = ParentComp->GetComponentRotation().UnrotateVector(GetUpVector());
224 EntryRightVec = ParentComp->GetComponentRotation().UnrotateVector(GetRightVector());
245 FVector CurInteractorToFlipPlaneVec = CurInteractorLocation - FPlane::PointPlaneProject(CurInteractorLocation,
FlipPlane);
250 if (FVector::DotProduct(CurInteractorToFlipPlaneVec,
EntryUpXYNeg) <= 0)
270 FVector RelativeUpVec = GetUpVector();
273 RelativeUpVec = ParentComp->GetComponentRotation().UnrotateVector(RelativeUpVec);
275 FVector CurrentUpVec = FVector(RelativeUpVec.X, RelativeUpVec.Y, 0).GetSafeNormal();
284 float CurTwist = FMath::Atan2(CurrentUpVec.Y, CurrentUpVec.X);
289 TwistDiff = FMath::RadiansToDegrees(EntryTwist - CurTwist - PI);
293 TwistDiff = FMath::RadiansToDegrees(EntryTwist - CurTwist);
302 if (FVector::DotProduct(CurInteractorToFlipPlaneVec,
EntryUpXYNeg) >= 0)
350 this->AddLocalRotation(FRotator(0, 0, -
TwistDiff));
362 uint8 GripID = GripInformation.
GripID;
378 FTransform ReversedRelativeTransform = FTransform(GripInformation.
RelativeTransform.ToInverseMatrixWithScale());
379 FTransform RelativeToGripTransform = ReversedRelativeTransform * this->GetComponentTransform();
391 qRotAtGrab = this->GetComponentTransform().GetRelativeTransform(CurrentRelativeTransform).GetRotation();
393 FVector ForwardVectorToUse = GetForwardVector();
397 ForwardVectorToUse = ParentComp->GetComponentRotation().UnrotateVector(ForwardVectorToUse);
413 FRotator RelativeRot = GetRelativeRotation();
423 this->SetComponentTickEnabled(
true);
428 this->SetComponentTickEnabled(
false);
521 if (OverridePrefix.IsNone())
522 bSecondarySlot ? OverridePrefix =
"VRGripS" : OverridePrefix =
"VRGripP";
534 CurHoldingControllers.Empty();
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()
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 FTransform Interactible_GetCurrentParentTransform(USceneComponent *SceneComponentToCheck)
UFUNCTION(BlueprintPure, Category = "VRInteractibleFunctions", meta = (bIgnoreSelf = "true"))
UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = (VRExpansionPlugin))
FVector InitialInteractorDropLocation
bool bReplicateMovement
UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface|Replication")
bool bOriginalReplicatesMovement
virtual void OnUnregister() override
float SecondarySlotRange
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GripSettings")
ESecondaryGripType SecondaryGripType_Implementation() override
FTransform InitialRelativeTransform
float PrimarySlotRange
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GripSettings")
float Damping
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRGripInterface")
float FlipingZone
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRMountComponent")
virtual void BeginPlay() override
void TickGrip_Implementation(UGripMotionControllerComponent *GrippingController, const FBPActorGripInformation &GripInformation, float DeltaTime) override
bool bIsInsideFrontFlipingZone
FVector InitialInteractorLocation
FVector InitialGripToForwardVec
UVRMountComponent(const FObjectInitializer &ObjectInitializer)
FVector LastPointOnForwardPlane
EGripCollisionType GetPrimaryGripType_Implementation(bool bIsSlot) override
void OnSecondaryGrip_Implementation(UGripMotionControllerComponent *GripOwningController, USceneComponent *SecondaryGripComponent, const FBPActorGripInformation &GripInformation) override
void OnChildGripRelease_Implementation(UGripMotionControllerComponent *ReleasingController, const FBPActorGripInformation &GripInformation, bool bWasSocketed=false) override
EGripMovementReplicationSettings GripMovementReplicationType_Implementation() override
FVector CurPointOnForwardPlane
void OnEndSecondaryUsed_Implementation() override
FBPGripPair HoldingGrip
UPROPERTY(BlueprintReadOnly, Category = "VRGripInterface")
FGameplayTagContainer GameplayTags
UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "GameplayTags")
float BreakDistance
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRGripInterface")
bool bLerpingOutOfFlipZone
EGripMovementReplicationSettings MovementReplicationSetting
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRGripInterface")
float Stiffness
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRGripInterface")
void SetGripPriority(int NewGripPriority)
UFUNCTION(BlueprintCallable, Category = "GripSettings")
FBPAdvGripSettings AdvancedGripSettings_Implementation() override
void OnUsed_Implementation() override
void ClosestGripSlotInRange_Implementation(FVector WorldLocation, bool bSecondarySlot, bool &bHadSlotInRange, FTransform &SlotWorldTransform, FName &SlotName, UGripMotionControllerComponent *CallingController=nullptr, FName OverridePrefix=NAME_None) override
void SetHeld_Implementation(UGripMotionControllerComponent *NewHoldingController, uint8 GripID, bool bNewIsHeld) override
bool AllowsMultipleGrips_Implementation() override
virtual void OnRegister() override
float FlipReajustYawSpeed
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRMountComponent")
void IsHeld_Implementation(TArray< FBPGripPair > &CurHoldingControllers, bool &bCurIsHeld) override
void OnChildGrip_Implementation(UGripMotionControllerComponent *GrippingController, const FBPActorGripInformation &GripInformation) override
void OnGripRelease_Implementation(UGripMotionControllerComponent *ReleasingController, const FBPActorGripInformation &GripInformation, bool bWasSocketed=false) override
bool bDenyGripping
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRGripInterface", meta = (ScriptName = "IsDen...
void OnInput_Implementation(FKey Key, EInputEvent KeyEvent) override
virtual void PreReplication(IRepChangedPropertyTracker &ChangedPropertyTracker) override
void OnSecondaryUsed_Implementation() override
void OnGrip_Implementation(UGripMotionControllerComponent *GrippingController, const FBPActorGripInformation &GripInformation) override
void OnEndUsed_Implementation() override
bool bIsHeld
UPROPERTY(BlueprintReadOnly, Category = "VRGripInterface", meta = (ScriptName = "IsCurrentlyHeld"))
bool bFirstEntryToHalfFlipZone
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override
bool bRepGameplayTags
UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface")
EVRInteractibleMountAxis MountRotationAxis
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRMountComponent")
bool GetGripScripts_Implementation(TArray< UVRGripScriptBase * > &ArrayReference) override
int GripPriority
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GripSettings")
bool SimulateOnDrop_Implementation() override
EGripLateUpdateSettings GripLateUpdateSetting_Implementation() override
bool RequestsSocketing_Implementation(USceneComponent *&ParentToSocketTo, FName &OptionalSocketName, FTransform_NetQuantize &RelativeTransform) override
EGripInterfaceTeleportBehavior TeleportBehavior_Implementation() override
void ResetInitialMountLocation()
UFUNCTION(BlueprintCallable, Category = "VRMountComponent")
void GetGripStiffnessAndDamping_Implementation(float &GripStiffnessOut, float &GripDampingOut) override
FVector InitialForwardVector
bool DenyGripping_Implementation(UGripMotionControllerComponent *GripInitiator=nullptr) override
bool bIsInsideBackFlipZone
void OnSecondaryGripRelease_Implementation(UGripMotionControllerComponent *GripOwningController, USceneComponent *ReleasingSecondaryGripComponent, const FBPActorGripInformation &GripInformation) override
float GripBreakDistance_Implementation() override
USTRUCT(BlueprintType, Category = "VRExpansionLibrary")
USTRUCT(BlueprintType, Category = "VRExpansionLibrary")
uint8 GripID
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GripPair")