This commit is contained in:
2023-09-05 19:59:40 +02:00
parent 362d216dfd
commit 72f64957a6
75 changed files with 1808 additions and 16 deletions

View File

@@ -109,13 +109,14 @@ void AFireworksPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputCompo
void AFireworksPawn::SetupGrabAttachment(EControllerHand Hand) {
FName Socket = Hand == EControllerHand::Left ? TEXT("SocketL") : TEXT("SocketR");
APickableObject* HeldObject = Hand == EControllerHand::Left ? HeldObject_L : HeldObject_R;
USkeletalMeshComponent* HandMesh = Hand == EControllerHand::Left ? LeftHandMesh : RightHandMesh;
FTransform HeldObjectTransformLocal = HeldObject->StaticMesh->GetSocketTransform(Socket, ERelativeTransformSpace::RTS_Actor);
// Set new values
FTransform NewTransform;
NewTransform.SetScale3D(FVector(1.f, 1.f, 1.f));
NewTransform.SetLocation(FVector(0.f, 0.f, 0.f));
NewTransform.SetLocation(IsSteamVR ? FVector(-10.f, 0.f, 0.f) : FVector(0.f, 0.f, 0.f));
NewTransform.SetRotation(HeldObjectTransformLocal.GetRotation().Inverse());
// Set new transform
@@ -137,7 +138,7 @@ bool AFireworksPawn::TryGrab(EControllerHand Hand)
HoveredActorL->StaticMesh->SetSimulatePhysics(false);
HoveredActorL->StaticMesh->SetRenderCustomDepth(false);
HeldObject_L = HoveredActorL;
HeldObject_L->AttachToComponent(MotionControllerL, FAttachmentTransformRules::KeepRelativeTransform);
HeldObject_L->AttachToComponent(MotionControllerL, FAttachmentTransformRules::KeepWorldTransform);
SetupGrabAttachment(EControllerHand::Left);
HeldObject_L->SetInstigator(this);
IsGrabbingL = true;
@@ -155,7 +156,7 @@ bool AFireworksPawn::TryGrab(EControllerHand Hand)
HoveredActorR->StaticMesh->SetSimulatePhysics(false);
HoveredActorR->StaticMesh->SetRenderCustomDepth(false);
HeldObject_R = HoveredActorR;
HeldObject_R->StaticMesh->AttachToComponent(MotionControllerR, FAttachmentTransformRules::KeepRelativeTransform);
HeldObject_R->AttachToComponent(MotionControllerR, FAttachmentTransformRules::KeepWorldTransform);
SetupGrabAttachment(EControllerHand::Right);
HeldObject_R->SetInstigator(this);
IsGrabbingR = true;