From c4320db5e0b3d985a44ce030ca43471886d78025 Mon Sep 17 00:00:00 2001 From: Foxim Date: Wed, 16 Apr 2025 22:12:16 +0200 Subject: [PATCH] fix: correct throw trajectory for throwable --- .../Characters/Components/ShootingComponent.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/Exo/Private/Characters/Components/ShootingComponent.cpp b/Source/Exo/Private/Characters/Components/ShootingComponent.cpp index 80096bd..d27b616 100644 --- a/Source/Exo/Private/Characters/Components/ShootingComponent.cpp +++ b/Source/Exo/Private/Characters/Components/ShootingComponent.cpp @@ -77,7 +77,7 @@ AActor* UShootingComponent::ExecuteLineTrace(float LineRange) // DEBUG if (bShowDebugLine) - DrawDebugLine(GetWorld(), ViewLocation, EndVector, FColor::Red, false, 1.0f, 0, 1.0f); + DrawDebugLine(GetWorld(), ViewLocation, EndVector, FColor::Red, false, 5.0f, 0, 1.0f); if (GetWorld()->LineTraceSingleByChannel(Hit, ViewLocation, EndVector, ECC_Visibility, QueryParams) && IsValid(Hit.GetActor()) && Hit.GetActor()->Implements()) @@ -264,12 +264,11 @@ void UShootingComponent::StopAiming() TargetFOV = DefaultFOV; } -void UShootingComponent::Throw() // Wymaga dopracowania +void UShootingComponent::Throw() { if (IsValid(ThrowableItem)) - { - FVector ForwardVector = PlayerCharacter->GetActorForwardVector(); - FVector DroppedPos = PlayerCharacter->GetActorLocation() + (ForwardVector * 100.f); + { + FVector DroppedPos = CameraManager->GetCameraLocation() + CameraManager->GetActorForwardVector() * 100.f; FTransform DroppedTransform = PlayerCharacter->GetActorTransform(); DroppedTransform.SetLocation(DroppedPos); @@ -285,7 +284,7 @@ void UShootingComponent::Throw() // Wymaga dopracowania ThrowedItem->ThrowableType = ThrowableItem->ThrowableType; FVector ThrowVector = (ThrowedItem->GetActorLocation() - PlayerCharacter->GetActorLocation()).GetSafeNormal(); - ThrowedItem->Mesh->SetPhysicsLinearVelocity(ThrowVector * 800.f); + ThrowedItem->Mesh->SetPhysicsLinearVelocity(ThrowVector * 1000.f); // Need force to change to the game if (ThrowableItem->Quantity <= 0) {