52 lines
1.4 KiB
C++
52 lines
1.4 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "ProjectileBase.h"
|
|
|
|
#include "OpenConflict/PlayerCharacter/DDICharacter.h"
|
|
|
|
// Sets default values
|
|
AProjectileBase::AProjectileBase()
|
|
{
|
|
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
|
PrimaryActorTick.bCanEverTick = true;
|
|
bReplicates = true;
|
|
bNetLoadOnClient = true;
|
|
|
|
InitialLifeSpan = 3.f;
|
|
|
|
|
|
collision = CreateDefaultSubobject<USphereComponent>("Collision");
|
|
RootComponent = collision;
|
|
collision->BodyInstance.SetCollisionProfileName(TEXT("BlockAllDynamic"));
|
|
|
|
projectileMesh = CreateDefaultSubobject<UStaticMeshComponent>("ProjectileMesh");
|
|
projectileMesh->SetupAttachment(collision);
|
|
|
|
projectileMotion = CreateDefaultSubobject<UProjectileMovementComponent>("ProjectileMovementComponent");
|
|
}
|
|
|
|
// Called when the game starts or when spawned
|
|
void AProjectileBase::BeginPlay()
|
|
{
|
|
Super::BeginPlay();
|
|
|
|
if (collision)
|
|
collision->OnComponentHit.AddDynamic(this, &AProjectileBase::OnHit);
|
|
|
|
}
|
|
|
|
// Called every frame
|
|
void AProjectileBase::Tick(float DeltaTime)
|
|
{
|
|
Super::Tick(DeltaTime);
|
|
|
|
}
|
|
|
|
|
|
void AProjectileBase::OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
|
|
{
|
|
// if (ADDICharacter* character = Cast<ADDICharacter>(OtherActor))
|
|
Destroy();
|
|
|
|
} |