2022-05-07 11:03:19 +00:00
|
|
|
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
|
|
|
|
|
|
#include "ProjectileBullet.h"
|
|
|
|
|
|
|
|
#include "GameFramework/Character.h"
|
2022-05-19 09:10:41 +00:00
|
|
|
#include "GameFramework/ProjectileMovementComponent.h"
|
2022-05-07 11:03:19 +00:00
|
|
|
#include "Kismet/GameplayStatics.h"
|
|
|
|
|
2022-05-19 09:10:41 +00:00
|
|
|
AProjectileBullet::AProjectileBullet()
|
|
|
|
{
|
|
|
|
ProjectileMovementComponent = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileMovementComponent"));
|
|
|
|
ProjectileMovementComponent->bRotationFollowsVelocity = true;
|
|
|
|
ProjectileMovementComponent->SetIsReplicated(true);
|
|
|
|
}
|
|
|
|
|
2022-05-07 11:03:19 +00:00
|
|
|
void AProjectileBullet::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
|
|
|
|
{
|
|
|
|
ACharacter* OwnerCharacter = Cast<ACharacter>(GetOwner());
|
|
|
|
if (OwnerCharacter)
|
|
|
|
{
|
|
|
|
AController* OwnerController = OwnerCharacter->Controller;
|
|
|
|
if (OwnerController)
|
|
|
|
{
|
|
|
|
UGameplayStatics::ApplyDamage(OtherActor, Damage, OwnerController, this, UDamageType::StaticClass());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Super::OnHit(HitComp, OtherActor, OtherComp, NormalImpulse, Hit);
|
|
|
|
}
|