Big update / almost working

This commit is contained in:
2023-06-13 22:53:48 +02:00
parent 25559b81e3
commit a6ce2a73d0
17 changed files with 4 additions and 63 deletions

View File

@@ -96,7 +96,6 @@ void AFireworksPawn::Tick(float DeltaTime)
Super::Tick(DeltaTime);
SampleHandVelocities();
TryUpdateLasers();
TryUpdateTeleportVisual();
}
// Called to bind functionality to input
@@ -282,20 +281,13 @@ void AFireworksPawn::TryUpdateLasers()
// Check if this hand is grabbing anything, if not - continue
if (!IsGrabbingL) {
// Check if is pointing at any widget - if yes, omit trace and show laser
if (WidgetInteractionL->IsOverHitTestVisibleWidget()) {
LaserL->SetHiddenInGame(false);
LaserL->SetRelativeScale3D(FVector(WidgetInteractionL->GetLastHitResult().Distance, LaserL->GetRelativeScale3D().Y, LaserL->GetRelativeScale3D().Z));
} // If not pointing widget, check if Laser (teleport) button is pressed - if yes, show laser
else if (TryShowLaserL)
if (TryShowLaserL)
{
FVector StartLocation = LaserL->GetComponentLocation();
FVector EndLocation = StartLocation + (WidgetInteractionL->GetForwardVector() * WidgetInteractionL->InteractionDistance);
GetWorld()->LineTraceSingleByChannel(CurrentLaserHitL, StartLocation, EndLocation, ECollisionChannel::ECC_Visibility);
LaserL->SetHiddenInGame(false);
LaserL->SetRelativeScale3D(FVector(CurrentLaserHitL.Distance, LaserL->GetRelativeScale3D().Y, LaserL->GetRelativeScale3D().Z));
LaserL->SetRelativeScale3D(FVector((CurrentLaserHitL.Distance >= 5.0f ? CurrentLaserHitL.Distance : 1000.0f), LaserL->GetRelativeScale3D().Y, LaserL->GetRelativeScale3D().Z));
} // If the laser is visible, and should not - hide it
else if(!LaserL->bHiddenInGame)
{
@@ -307,65 +299,17 @@ void AFireworksPawn::TryUpdateLasers()
// Check if this hand is grabbing anything, if not - continue
if (!IsGrabbingR) {
// Check if is pointing at any widget - if yes, omit trace and show laser
if (WidgetInteractionR->IsOverHitTestVisibleWidget()) {
LaserR->SetHiddenInGame(false);
LaserR->SetRelativeScale3D(FVector(WidgetInteractionR->GetLastHitResult().Distance, LaserR->GetRelativeScale3D().Y, LaserR->GetRelativeScale3D().Z));
} // If not pointing widget, check if Laser (teleport) button is pressed - if yes, show laser
else if (TryShowLaserR)
if (TryShowLaserR)
{
FVector StartLocation = LaserR->GetComponentLocation();
FVector EndLocation = StartLocation + (WidgetInteractionR->GetForwardVector() * WidgetInteractionR->InteractionDistance);
GetWorld()->LineTraceSingleByChannel(CurrentLaserHitR, StartLocation, EndLocation, ECollisionChannel::ECC_Visibility);
LaserR->SetHiddenInGame(false);
LaserR->SetRelativeScale3D(FVector(CurrentLaserHitR.Distance, LaserR->GetRelativeScale3D().Y, LaserR->GetRelativeScale3D().Z));
LaserR->SetRelativeScale3D(FVector((CurrentLaserHitR.Distance >= 5.0f ? CurrentLaserHitR.Distance : 1000.0f), LaserR->GetRelativeScale3D().Y, LaserR->GetRelativeScale3D().Z));
} // If the laser is visible, and should not - hide it
else if (!LaserR->bHiddenInGame)
{
LaserR->SetHiddenInGame(true);
}
}
}
// Try update teleport visual
void AFireworksPawn::TryUpdateTeleportVisual()
{
bool RightLaserCanTeleport = !LaserR->bHiddenInGame && (IsValid(CurrentLaserHitR.GetActor()) ? CurrentLaserHitR.GetActor()->ActorHasTag(TEXT("Ground")) : false);
bool LeftLaserCanTeleport = !LaserL->bHiddenInGame && (IsValid(CurrentLaserHitL.GetActor()) ? CurrentLaserHitL.GetActor()->ActorHasTag(TEXT("Ground")) : false);
// Firstly cover the case of both hands pointing at ground with laser
if (RightLaserCanTeleport && LeftLaserCanTeleport)
{
if (DominatingHand == EControllerHand::Left)
{
TeleportVisual->SetActorHiddenInGame(false);
TeleportVisual->SetActorLocation(CurrentLaserHitL.Location);
return;
}
else
{
TeleportVisual->SetActorHiddenInGame(false);
TeleportVisual->SetActorLocation(CurrentLaserHitR.Location);
return;
}
}
// Check if any hand is pointing laser at the ground
if (LeftLaserCanTeleport)
{
TeleportVisual->SetActorHiddenInGame(false);
TeleportVisual->SetActorLocation(CurrentLaserHitL.Location);
return;
}
else if (RightLaserCanTeleport)
{
TeleportVisual->SetActorHiddenInGame(false);
TeleportVisual->SetActorLocation(CurrentLaserHitR.Location);
return;
}
else {
TeleportVisual->SetActorHiddenInGame(true);
}
}