Create ThrowThrowable method
This commit is contained in:
parent
1023a4f2b7
commit
42f99410e0
|
@ -13,6 +13,7 @@
|
||||||
#include "GameFramework/CharacterMovementComponent.h"
|
#include "GameFramework/CharacterMovementComponent.h"
|
||||||
#include "InputMappingContext.h"
|
#include "InputMappingContext.h"
|
||||||
#include "EnemyCharacter.h"
|
#include "EnemyCharacter.h"
|
||||||
|
#include "Throwable.h"
|
||||||
|
|
||||||
#define COLLISION_WEAPON ECC_GameTraceChannel1
|
#define COLLISION_WEAPON ECC_GameTraceChannel1
|
||||||
|
|
||||||
|
@ -561,3 +562,17 @@ float APlayerCharacter::GetWeaponSpread()
|
||||||
|
|
||||||
return CurrentWeapon->GetWeaponProperties()->WeaponSpread;
|
return CurrentWeapon->GetWeaponProperties()->WeaponSpread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void APlayerCharacter::ThrowThrowable()
|
||||||
|
{
|
||||||
|
FVector Location;
|
||||||
|
FVector BoxExtent;
|
||||||
|
GetActorBounds(true, Location, BoxExtent, false);
|
||||||
|
|
||||||
|
FVector SpawnLocation = FVector(Location.Z, Location.Y + (BoxExtent.Y / 2), Location.Z + (BoxExtent.Z / 2));
|
||||||
|
|
||||||
|
AThrowable* Throwable = GetWorld()->SpawnActor<AThrowable>(SpawnLocation, FRotator::ZeroRotator);
|
||||||
|
|
||||||
|
// TODO: Set the collision size to the size of the static mesh in the throwable
|
||||||
|
//throwable->GetSphereComponent()->SetSphereRadius();
|
||||||
|
}
|
||||||
|
|
|
@ -175,6 +175,8 @@ public:
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
float GetWeaponSpread();
|
float GetWeaponSpread();
|
||||||
|
|
||||||
|
void ThrowThrowable();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CalculateHits(TArray<FHitResult>* hits) override;
|
virtual void CalculateHits(TArray<FHitResult>* hits) override;
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,6 @@ AThrowable::AThrowable()
|
||||||
SphereComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndProbe);
|
SphereComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndProbe);
|
||||||
SphereComponent->SetCollisionProfileName(FName("IgnoreOnlyPawn"));
|
SphereComponent->SetCollisionProfileName(FName("IgnoreOnlyPawn"));
|
||||||
SphereComponent->SetupAttachment(RootComponent);
|
SphereComponent->SetupAttachment(RootComponent);
|
||||||
|
|
||||||
HealthComponent->OnDeath.BindUFunction(this, "Explode");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the game starts or when spawned
|
// Called when the game starts or when spawned
|
||||||
|
|
|
@ -31,4 +31,6 @@ public:
|
||||||
UPrimitiveComponent* OtherComp,
|
UPrimitiveComponent* OtherComp,
|
||||||
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
|
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
|
||||||
|
|
||||||
|
USphereComponent* GetSphereComponent() const { return SphereComponent; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue