Add functionality to ThrowThrowable
This commit is contained in:
parent
19d452be5c
commit
d3e775758d
|
@ -63,7 +63,7 @@ APlayerCharacter::APlayerCharacter()
|
||||||
// Setup the character perception component
|
// Setup the character perception component
|
||||||
PerceptionSource = CreateDefaultSubobject<UAIPerceptionStimuliSourceComponent>(TEXT("Perception Source Stimuli"));
|
PerceptionSource = CreateDefaultSubobject<UAIPerceptionStimuliSourceComponent>(TEXT("Perception Source Stimuli"));
|
||||||
PerceptionSource->bAutoRegister = true;
|
PerceptionSource->bAutoRegister = true;
|
||||||
|
|
||||||
this->Tags.Add(FName("Player"));
|
this->Tags.Add(FName("Player"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -581,7 +581,7 @@ void APlayerCharacter::ThrowWeaponCallback()
|
||||||
FVector BoxExtent;
|
FVector BoxExtent;
|
||||||
GetActorBounds(true, Location, BoxExtent, false);
|
GetActorBounds(true, Location, BoxExtent, false);
|
||||||
|
|
||||||
FVector SpawnLocation = (BoxExtent.X * GetActorForwardVector()) * 2;
|
FVector SpawnLocation = (BoxExtent.X * GetActorForwardVector()) * 2;
|
||||||
SpawnLocation += Location;
|
SpawnLocation += Location;
|
||||||
SpawnLocation.Z += BoxExtent.Z;
|
SpawnLocation.Z += BoxExtent.Z;
|
||||||
|
|
||||||
|
@ -596,11 +596,19 @@ void APlayerCharacter::ThrowWeaponCallback()
|
||||||
|
|
||||||
void APlayerCharacter::ThrowExplosiveCallback()
|
void APlayerCharacter::ThrowExplosiveCallback()
|
||||||
{
|
{
|
||||||
auto throwable = ThrowThrowable();
|
if (ThrowableInventory.Num() > 0)
|
||||||
|
{
|
||||||
|
FVector Location;
|
||||||
|
FVector BoxExtent;
|
||||||
|
GetActorBounds(true, Location, BoxExtent, false);
|
||||||
|
|
||||||
// TODO: Set the collision size to the size of the static mesh in the throwable
|
FVector SpawnLocation = (BoxExtent.X * GetActorForwardVector()) * 2;
|
||||||
// throwable->GetSphereComponent()->SetSphereRadius();
|
SpawnLocation += Location;
|
||||||
|
SpawnLocation += (25.0f * GetActorForwardVector());
|
||||||
|
SpawnLocation.Z += BoxExtent.Z;
|
||||||
|
|
||||||
|
AThrowable* Throwable = GetWorld()->SpawnActor<AThrowable>(ThrowableInventory.Pop(), SpawnLocation, FRotator::ZeroRotator);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AThrowable* APlayerCharacter::ThrowThrowable()
|
AThrowable* APlayerCharacter::ThrowThrowable()
|
||||||
|
|
Loading…
Reference in New Issue