fix: correct throw trajectory for throwable
This commit is contained in:
parent
2b6bdf9f80
commit
c4320db5e0
|
|
@ -77,7 +77,7 @@ AActor* UShootingComponent::ExecuteLineTrace(float LineRange)
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
if (bShowDebugLine)
|
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) &&
|
if (GetWorld()->LineTraceSingleByChannel(Hit, ViewLocation, EndVector, ECC_Visibility, QueryParams) &&
|
||||||
IsValid(Hit.GetActor()) && Hit.GetActor()->Implements<UDamageable>())
|
IsValid(Hit.GetActor()) && Hit.GetActor()->Implements<UDamageable>())
|
||||||
|
|
@ -264,12 +264,11 @@ void UShootingComponent::StopAiming()
|
||||||
TargetFOV = DefaultFOV;
|
TargetFOV = DefaultFOV;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UShootingComponent::Throw() // Wymaga dopracowania
|
void UShootingComponent::Throw()
|
||||||
{
|
{
|
||||||
if (IsValid(ThrowableItem))
|
if (IsValid(ThrowableItem))
|
||||||
{
|
{
|
||||||
FVector ForwardVector = PlayerCharacter->GetActorForwardVector();
|
FVector DroppedPos = CameraManager->GetCameraLocation() + CameraManager->GetActorForwardVector() * 100.f;
|
||||||
FVector DroppedPos = PlayerCharacter->GetActorLocation() + (ForwardVector * 100.f);
|
|
||||||
|
|
||||||
FTransform DroppedTransform = PlayerCharacter->GetActorTransform();
|
FTransform DroppedTransform = PlayerCharacter->GetActorTransform();
|
||||||
DroppedTransform.SetLocation(DroppedPos);
|
DroppedTransform.SetLocation(DroppedPos);
|
||||||
|
|
@ -285,7 +284,7 @@ void UShootingComponent::Throw() // Wymaga dopracowania
|
||||||
ThrowedItem->ThrowableType = ThrowableItem->ThrowableType;
|
ThrowedItem->ThrowableType = ThrowableItem->ThrowableType;
|
||||||
|
|
||||||
FVector ThrowVector = (ThrowedItem->GetActorLocation() - PlayerCharacter->GetActorLocation()).GetSafeNormal();
|
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)
|
if (ThrowableItem->Quantity <= 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user