Skip to content

Commit

Permalink
[Fix] Cable becoming invisible after fail then launch again and grapp…
Browse files Browse the repository at this point in the history
…ling
  • Loading branch information
iJotape4 committed Nov 6, 2024
1 parent d0ee522 commit 08276bb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions GameJamPlus2024/Config/DefaultEngine.ini
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ ManualIPAddress=
+ClassRedirects=(OldName="/Script/GameJamPlus2024.WB_HealthBar",NewName="/Script/GameJamPlus2024.HealthBar")
+ClassRedirects=(OldName="/Script/GameJamPlus2024.GrapplingHookUpgrade",NewName="/Script/GameJamPlus2024.GrapplingHookComponent")
+ClassRedirects=(OldName="/Script/GameJamPlus2024.WindMill",NewName="/Script/GameJamPlus2024.WaterMill")
+FunctionRedirects=(OldName="/Script/GameJamPlus2024.GrapplingHookComponent.OnReverseCableFinished",NewName="/Script/GameJamPlus2024.GrapplingHookComponent.OnReverseCableAfterFailFinished")

[/Script/Engine.UserInterfaceSettings]
RenderFocusRule=NavigationOnly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ void UGrapplingHookComponent::HookGrappling(const FInputActionValue& Value)
void UGrapplingHookComponent::SetCableComponentVisibility(bool bVisible)
{
CableComponent->SetVisibility(bVisible);
if(!bVisible && CableTimeline)
{
CableTimeline->Stop();
}
}

void UGrapplingHookComponent::BeginPlay()
Expand Down Expand Up @@ -102,13 +98,22 @@ void UGrapplingHookComponent::OnTimelineFinished()
CableTimeline->Reverse();
FLatentActionInfo LatentInfo;
LatentInfo.CallbackTarget = this;
LatentInfo.ExecutionFunction = FName("SetCableComponentVisibility", false);
LatentInfo.ExecutionFunction = FName("OnReverseCableAfterFailFinished");
LatentInfo.Linkage = 0;
LatentInfo.UUID = __LINE__;
UKismetSystemLibrary::Delay(GetWorld(), 0.3f, LatentInfo);
}
}

void UGrapplingHookComponent::OnReverseCableAfterFailFinished()
{
if(!isGrappling)
SetCableComponentVisibility(false);

if(CableTimeline)
CableTimeline->Stop();
}

void UGrapplingHookComponent::HookLineTrace(FHitResult& OutHit)
{
if (!InitializeComponents()) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class GAMEJAMPLUS2024_API UGrapplingHookComponent : public UCharacterUpgrade
UFUNCTION()
void OnTimelineFinished();

UFUNCTION()
void OnReverseCableAfterFailFinished();

protected:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Grappling Hook", meta = (AllowPrivateAccess = "true"))
UCableComponent* CableComponent;
Expand Down

0 comments on commit 08276bb

Please sign in to comment.