Main Rebase #5
@@ -2,7 +2,10 @@
|
||||
|
||||
|
||||
#include "DDICharacter.h"
|
||||
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "GameFramework/SpringArmComponent.h"
|
||||
#include "OpenConflict/Weapons/Projectiles/ProjectileBase.h"
|
||||
|
||||
// Sets default values
|
||||
ADDICharacter::ADDICharacter()
|
||||
@@ -17,6 +20,12 @@ ADDICharacter::ADDICharacter()
|
||||
CameraComponent->SetRelativeLocation(FVector(0.0f, 0.0f, 50.0f));
|
||||
CameraComponent->bUsePawnControlRotation = true;
|
||||
|
||||
HealthComponent = CreateDefaultSubobject<UDDIHealth>(TEXT("HealthComponent"));
|
||||
|
||||
GetCapsuleComponent()->SetCollisionProfileName(TEXT("BlockAllDynamic"));
|
||||
GetCapsuleComponent()->SetGenerateOverlapEvents(true);
|
||||
GetCapsuleComponent()->SetNotifyRigidBodyCollision(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +34,11 @@ void ADDICharacter::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
if (GetCapsuleComponent())
|
||||
{
|
||||
GetCapsuleComponent()->OnComponentHit.AddDynamic(this, &ADDICharacter::OnHit);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
@@ -34,4 +48,13 @@ void ADDICharacter::Tick(float DeltaTime)
|
||||
|
||||
}
|
||||
|
||||
void ADDICharacter::OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
|
||||
{
|
||||
if (OtherActor->Owner == this)
|
||||
return;
|
||||
|
||||
AProjectileBase* Projectile = Cast<AProjectileBase>(OtherActor);
|
||||
|
||||
if (HealthComponent && Projectile)
|
||||
HealthComponent->TakeDamage(10);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "Components/DDIHealth.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "DDICharacter.generated.h"
|
||||
|
||||
@@ -12,20 +13,50 @@ UCLASS()
|
||||
class OPENCONFLICT_API ADDICharacter : public ACharacter
|
||||
{
|
||||
GENERATED_BODY()
|
||||
/*UPROPERTY and UFUNCTION declarations*/
|
||||
private:
|
||||
/*Properties*/
|
||||
|
||||
public:
|
||||
// Sets default values for this character's properties
|
||||
ADDICharacter();
|
||||
/*Functions*/
|
||||
|
||||
protected:
|
||||
/*Properties*/
|
||||
|
||||
/*Functions*/
|
||||
|
||||
public:
|
||||
/*Properties*/
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Camera")
|
||||
UCameraComponent* CameraComponent;
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Health")
|
||||
UDDIHealth* HealthComponent;
|
||||
|
||||
/*Functions*/
|
||||
UFUNCTION()
|
||||
void OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);
|
||||
|
||||
|
||||
/*C++ only declarations*/
|
||||
private:
|
||||
/*Properties*/
|
||||
|
||||
/*Functions*/
|
||||
|
||||
protected:
|
||||
/*Properties*/
|
||||
|
||||
/*Functions*/
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
/*Properties*/
|
||||
|
||||
/*Functions*/
|
||||
// Sets default values for this character's properties
|
||||
ADDICharacter();
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Camera")
|
||||
UCameraComponent* CameraComponent;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user