-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBullet.cpp
More file actions
63 lines (48 loc) · 1.81 KB
/
Copy pathBullet.cpp
File metadata and controls
63 lines (48 loc) · 1.81 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
52
53
54
55
56
57
58
59
60
61
62
63
// Fill out your copyright notice in the Description page of Project Settings.
#include "Bullet.h"
#include "Kismet/GameplayStatics.h"
#include "Engine/StaticMesh.h"
#include "PlayerActor.h"
#include "Engine.h"
#include "Engine/World.h"
// Sets default values
ABullet::ABullet(const class FObjectInitializer& PCIP)
{
// 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;
// The bullet will simulate physics using its bounding sphere
ProxSphere = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("ProxSphere"));
RootComponent = ProxSphere;
ProxSphere->OnComponentBeginOverlap.AddDynamic(this, &ABullet::Prox);
// For the bullet, the mesh is "dumb". It just tags along with whatever
// the ProxSphere is doing, since the ProxSphere is going to respond to collisions
// with objects. Attach the Mesh to the ProxSphere.
Mesh = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Mesh"));
Mesh->SetupAttachment(ProxSphere);
Damage = 50;
//SetLifeSpan(2);
}
void ABullet::Prox_Implementation(UPrimitiveComponent* HitComp, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex,
bool bFromSweep, const FHitResult & SweepResult)
{
if (OtherComp != OtherActor->GetRootComponent())
{
// don't collide with anything other than the actors root component
return;
}
//GEngine->AddOnScreenDebugMessage(0, 5.f, FColor::Yellow, "Inside Prox_implementation in bullet");
OtherActor->TakeDamage(Damage, FDamageEvent(), NULL, this);
Destroy();
}
// Called when the game starts or when spawned
void ABullet::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ABullet::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}