-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerWeapon.cpp
More file actions
58 lines (41 loc) · 1.48 KB
/
Copy pathPlayerWeapon.cpp
File metadata and controls
58 lines (41 loc) · 1.48 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
// Fill out your copyright notice in the Description page of Project Settings.
#include "PlayerWeapon.h"
#include "Kismet/GameplayStatics.h"
#include "Engine/StaticMesh.h"
#include "PlayerActor.h"
#include "Enemy.h"
#include "Engine.h"
#include "Engine/World.h"
// Sets default values
APlayerWeapon::APlayerWeapon(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;
ProxCapsule = PCIP.CreateDefaultSubobject<UCapsuleComponent>(this, TEXT("ProxCapsule"));
RootComponent = ProxCapsule;
ProxCapsule->OnComponentBeginOverlap.AddDynamic(this, &APlayerWeapon::Prox);
Mesh = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Mesh"));
Mesh->SetupAttachment(ProxCapsule);
Damage = 1;
}
void APlayerWeapon::Prox_Implementation(class 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;
}
OtherActor->TakeDamage(Damage, FDamageEvent(), NULL, this);
}
// Called when the game starts or when spawned
void APlayerWeapon::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void APlayerWeapon::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}