Big update / almost working
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -96,7 +96,6 @@ void AFireworksPawn::Tick(float DeltaTime)
|
|||||||
Super::Tick(DeltaTime);
|
Super::Tick(DeltaTime);
|
||||||
SampleHandVelocities();
|
SampleHandVelocities();
|
||||||
TryUpdateLasers();
|
TryUpdateLasers();
|
||||||
TryUpdateTeleportVisual();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called to bind functionality to input
|
// Called to bind functionality to input
|
||||||
@@ -282,20 +281,13 @@ void AFireworksPawn::TryUpdateLasers()
|
|||||||
|
|
||||||
// Check if this hand is grabbing anything, if not - continue
|
// Check if this hand is grabbing anything, if not - continue
|
||||||
if (!IsGrabbingL) {
|
if (!IsGrabbingL) {
|
||||||
|
if (TryShowLaserL)
|
||||||
// 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)
|
|
||||||
{
|
{
|
||||||
FVector StartLocation = LaserL->GetComponentLocation();
|
FVector StartLocation = LaserL->GetComponentLocation();
|
||||||
FVector EndLocation = StartLocation + (WidgetInteractionL->GetForwardVector() * WidgetInteractionL->InteractionDistance);
|
FVector EndLocation = StartLocation + (WidgetInteractionL->GetForwardVector() * WidgetInteractionL->InteractionDistance);
|
||||||
GetWorld()->LineTraceSingleByChannel(CurrentLaserHitL, StartLocation, EndLocation, ECollisionChannel::ECC_Visibility);
|
GetWorld()->LineTraceSingleByChannel(CurrentLaserHitL, StartLocation, EndLocation, ECollisionChannel::ECC_Visibility);
|
||||||
|
|
||||||
LaserL->SetHiddenInGame(false);
|
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
|
} // If the laser is visible, and should not - hide it
|
||||||
else if(!LaserL->bHiddenInGame)
|
else if(!LaserL->bHiddenInGame)
|
||||||
{
|
{
|
||||||
@@ -307,65 +299,17 @@ void AFireworksPawn::TryUpdateLasers()
|
|||||||
|
|
||||||
// Check if this hand is grabbing anything, if not - continue
|
// Check if this hand is grabbing anything, if not - continue
|
||||||
if (!IsGrabbingR) {
|
if (!IsGrabbingR) {
|
||||||
|
if (TryShowLaserR)
|
||||||
// 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)
|
|
||||||
{
|
{
|
||||||
FVector StartLocation = LaserR->GetComponentLocation();
|
FVector StartLocation = LaserR->GetComponentLocation();
|
||||||
FVector EndLocation = StartLocation + (WidgetInteractionR->GetForwardVector() * WidgetInteractionR->InteractionDistance);
|
FVector EndLocation = StartLocation + (WidgetInteractionR->GetForwardVector() * WidgetInteractionR->InteractionDistance);
|
||||||
GetWorld()->LineTraceSingleByChannel(CurrentLaserHitR, StartLocation, EndLocation, ECollisionChannel::ECC_Visibility);
|
GetWorld()->LineTraceSingleByChannel(CurrentLaserHitR, StartLocation, EndLocation, ECollisionChannel::ECC_Visibility);
|
||||||
|
|
||||||
LaserR->SetHiddenInGame(false);
|
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
|
} // If the laser is visible, and should not - hide it
|
||||||
else if (!LaserR->bHiddenInGame)
|
else if (!LaserR->bHiddenInGame)
|
||||||
{
|
{
|
||||||
LaserR->SetHiddenInGame(true);
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -176,7 +176,4 @@ public:
|
|||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void TryUpdateLasers();
|
void TryUpdateLasers();
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void TryUpdateTeleportVisual();
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user