2022-05-04 17:17:25 +00:00
|
|
|
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
|
|
|
|
|
|
#include "Projectile.h"
|
|
|
|
|
|
|
|
#include "Components/BoxComponent.h"
|
2022-05-05 10:59:50 +00:00
|
|
|
#include "GameFramework/ProjectileMovementComponent.h"
|
2022-05-05 12:15:25 +00:00
|
|
|
#include "Kismet/GameplayStatics.h"
|
2022-05-04 17:17:25 +00:00
|
|
|
|
|
|
|
AProjectile::AProjectile()
|
|
|
|
{
|
|
|
|
PrimaryActorTick.bCanEverTick = true;
|
2022-05-05 12:15:25 +00:00
|
|
|
bReplicates = true;
|
2022-05-04 17:17:25 +00:00
|
|
|
|
2022-05-05 12:15:25 +00:00
|
|
|
CollisionBox = CreateDefaultSubobject<UBoxComponent>(TEXT("CollisionBox"));
|
2022-05-04 17:17:25 +00:00
|
|
|
SetRootComponent(CollisionBox);
|
|
|
|
CollisionBox->SetCollisionObjectType(ECollisionChannel::ECC_WorldDynamic);
|
|
|
|
CollisionBox->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
|
|
|
|
CollisionBox->SetCollisionResponseToChannels(ECollisionResponse::ECR_Ignore);
|
|
|
|
CollisionBox->SetCollisionResponseToChannel(ECollisionChannel::ECC_Visibility, ECollisionResponse::ECR_Block);
|
|
|
|
CollisionBox->SetCollisionResponseToChannel(ECollisionChannel::ECC_WorldStatic, ECollisionResponse::ECR_Block);
|
2022-05-05 10:59:50 +00:00
|
|
|
|
|
|
|
ProjectileMovementComponent = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileMovementComponent"));
|
|
|
|
ProjectileMovementComponent->bRotationFollowsVelocity = true;
|
2022-05-04 17:17:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AProjectile::BeginPlay()
|
|
|
|
{
|
|
|
|
Super::BeginPlay();
|
2022-05-05 12:15:25 +00:00
|
|
|
|
|
|
|
if (Tracer)
|
|
|
|
{
|
|
|
|
TracerComponent = UGameplayStatics::SpawnEmitterAttached(
|
|
|
|
Tracer,
|
|
|
|
CollisionBox,
|
|
|
|
FName(),
|
|
|
|
GetActorLocation(),
|
|
|
|
GetActorRotation(),
|
|
|
|
EAttachLocation::KeepWorldPosition
|
|
|
|
);
|
|
|
|
}
|
2022-05-04 17:17:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AProjectile::Tick(float DeltaTime)
|
|
|
|
{
|
|
|
|
Super::Tick(DeltaTime);
|
|
|
|
}
|