https://differentdirection.youtrack.cloud/issue/OC-3/Replication-Projectiles complete #3
@@ -2,7 +2,10 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "DDICharacter.h"
|
#include "DDICharacter.h"
|
||||||
|
|
||||||
|
#include "Components/CapsuleComponent.h"
|
||||||
#include "GameFramework/SpringArmComponent.h"
|
#include "GameFramework/SpringArmComponent.h"
|
||||||
|
#include "OpenConflict/Weapons/Projectiles/ProjectileBase.h"
|
||||||
|
|
||||||
// Sets default values
|
// Sets default values
|
||||||
ADDICharacter::ADDICharacter()
|
ADDICharacter::ADDICharacter()
|
||||||
@@ -17,6 +20,12 @@ ADDICharacter::ADDICharacter()
|
|||||||
CameraComponent->SetRelativeLocation(FVector(0.0f, 0.0f, 50.0f));
|
CameraComponent->SetRelativeLocation(FVector(0.0f, 0.0f, 50.0f));
|
||||||
CameraComponent->bUsePawnControlRotation = true;
|
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();
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
if (GetCapsuleComponent())
|
||||||
|
{
|
||||||
|
GetCapsuleComponent()->OnComponentHit.AddDynamic(this, &ADDICharacter::OnHit);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every frame
|
// 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 "CoreMinimal.h"
|
||||||
#include "Camera/CameraComponent.h"
|
#include "Camera/CameraComponent.h"
|
||||||
|
#include "Components/DDIHealth.h"
|
||||||
#include "GameFramework/Character.h"
|
#include "GameFramework/Character.h"
|
||||||
#include "DDICharacter.generated.h"
|
#include "DDICharacter.generated.h"
|
||||||
|
|
||||||
@@ -12,20 +13,50 @@ UCLASS()
|
|||||||
class OPENCONFLICT_API ADDICharacter : public ACharacter
|
class OPENCONFLICT_API ADDICharacter : public ACharacter
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
/*UPROPERTY and UFUNCTION declarations*/
|
||||||
|
private:
|
||||||
|
/*Properties*/
|
||||||
|
|
||||||
public:
|
/*Functions*/
|
||||||
// Sets default values for this character's properties
|
|
||||||
ADDICharacter();
|
|
||||||
|
|
||||||
protected:
|
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
|
// Called when the game starts or when spawned
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/*Properties*/
|
||||||
|
|
||||||
|
/*Functions*/
|
||||||
|
// Sets default values for this character's properties
|
||||||
|
ADDICharacter();
|
||||||
// Called every frame
|
// Called every frame
|
||||||
virtual void Tick(float DeltaTime) override;
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Camera")
|
|
||||||
UCameraComponent* CameraComponent;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user