4#include "GameFramework/Character.h"
8 : Super(ObjectInitializer)
10 this->SetGenerateOverlapEvents(
true);
11 this->PrimaryComponentTick.bStartWithTickEnabled =
false;
12 PrimaryComponentTick.bCanEverTick =
true;
28 this->SetCollisionResponseToAllChannels(ECR_Overlap);
41void UVRButtonComponent::GetLifetimeReplicatedProps(TArray< class FLifetimeProperty > & OutLifetimeProps)
const
43 Super::GetLifetimeReplicatedProps(OutLifetimeProps);
53 Super::PreReplication(ChangedPropertyTracker);
83 Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
85 const float WorldTime = GetWorld()->GetRealTimeSeconds();
101 if (CheckDepth > 0.0f)
104 float ClampMinDepth = 0.0f;
136 this->SetComponentTickEnabled(
false);
171bool UVRButtonComponent::IsValidOverlap_Implementation(UPrimitiveComponent * OverlapComponent)
175 if (!OverlapComponent || OverlapComponent == GetAttachParent() || OverlapComponent->GetAttachParent() == GetAttachParent())
179 AActor * OverlapOwner = OverlapComponent->GetOwner();
180 if (OverlapOwner && OverlapOwner->IsA(ACharacter::StaticClass()))
185 USceneComponent * OurAttachParent = OverlapComponent->GetAttachParent();
186 if (OurAttachParent && OurAttachParent->IsA(UMotionControllerComponent::StaticClass()))
190 if (OverlapComponent->GetClass()->ImplementsInterface(UVRGripInterface::StaticClass()))
192 TArray<FBPGripPair> Controllers;
194 IVRGripInterface::Execute_IsHeld(OverlapComponent, Controllers, bIsHeld);
199 else if(OverlapOwner && OverlapOwner->GetClass()->ImplementsInterface(UVRGripInterface::StaticClass()))
201 TArray<FBPGripPair> Controllers;
203 IVRGripInterface::Execute_IsHeld(OverlapOwner, Controllers, bIsHeld);
227 if (OverlapOwner && OverlapOwner->IsA(ACharacter::StaticClass()))
236 TArray<FBPGripPair> Controllers;
240 if (bIsHeld && Controllers.Num())
242 AActor * ControllerOwner = Controllers[0].HoldingController !=
nullptr ? Controllers[0].HoldingController->GetOwner() :
nullptr;
250 else if (OverlapOwner && OverlapOwner->GetClass()->ImplementsInterface(UVRGripInterface::StaticClass()))
252 TArray<FBPGripPair> Controllers;
254 IVRGripInterface::Execute_IsHeld(OverlapOwner, Controllers, bIsHeld);
256 if (bIsHeld && Controllers.Num())
258 AActor * ControllerOwner = Controllers[0].HoldingController !=
nullptr ? Controllers[0].HoldingController->GetOwner() :
nullptr;
288 InitialComponentLoc = OriginalBaseTransform.InverseTransformPosition(this->GetComponentLocation());
291 this->SetComponentTickEnabled(
true);
335 if (!bLerpToPosition)
337 float ClampMinDepth = 0.0f;
343 float NewDepth = FMath::Clamp(ClampMinDepth, -
DepressDistance, ClampMinDepth);
347 this->SetComponentTickEnabled(
true);
364 if (bCallButtonChangedEvent)