-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBullet.cpp
More file actions
52 lines (40 loc) · 1.23 KB
/
Copy pathBullet.cpp
File metadata and controls
52 lines (40 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Fill out your copyright notice in the Description page of Project Settings.
#include "Bullet.h"
#include "Bullet.h"
#include "GameFramework/ProjectileMovementComponent.h"
#include "Kismet/GameplayStatics.h"
#include "Engine/BlockingVolume.h"
#include "Enemy.h"
// Sets default values
ABullet::ABullet()
{
// 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;
RootComp = CreateAbstractDefaultSubobject<USceneComponent>(TEXT("RootComp"));
RootComponent = RootComp;
BulletMS = CreateAbstractDefaultSubobject<UStaticMeshComponent>(TEXT("BulletMesh"));
BulletMS->SetupAttachment(RootComponent);
ProjectileMovementComp = CreateAbstractDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileMovementComp"));
}
// Called when the game starts or when spawned
void ABullet::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ABullet::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ABullet::NotifyActorBeginOverlap(AActor* Other)
{
Super::NotifyActorBeginOverlap(Other);
AEnemy* Enemy = Cast<AEnemy>(Other);
if (Enemy) {
Enemy->OnDeath();
Destroy();
}
else if (Cast<ABlockingVolume>(Other)) {
Destroy();
}
}