Implemented basic grenade interaction: - Player can pick up, throw, and drop grenades. To-do: - Refine throwing mechanics (e.g. direction, force). - Clean up and refactor related code.
46 lines
1.0 KiB
C++
46 lines
1.0 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "Items/ThrowableBase.h"
|
|
|
|
#include "Characters/Components/ShootingComponent.h"
|
|
|
|
AThrowableBase::AThrowableBase()
|
|
{
|
|
PrimaryActorTick.bCanEverTick = true;
|
|
|
|
RootSceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
|
|
SetRootComponent(RootSceneComponent);
|
|
Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
|
|
Mesh->SetupAttachment(GetRootComponent());
|
|
Mesh->SetSimulatePhysics(true);
|
|
|
|
}
|
|
|
|
void AThrowableBase::Interact_Implementation(AExoPlayerCharacter* PlayerCharacter)
|
|
{
|
|
if (PlayerCharacter->ShootingComponent->PickUpThrow(this))
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
}
|
|
|
|
void AThrowableBase::EffectActivate()
|
|
{
|
|
if (ThrowableType == ThrowableType::Hit)
|
|
{
|
|
UE_LOG(LogTemp, Display, TEXT("Throwable Hit"));
|
|
}
|
|
if (ThrowableType == ThrowableType::Explode)
|
|
{
|
|
UE_LOG(LogTemp, Display, TEXT("Throwable Explode"));
|
|
}
|
|
if (ThrowableType == ThrowableType::Area)
|
|
{
|
|
UE_LOG(LogTemp, Display, TEXT("Throwable Area"));
|
|
}
|
|
}
|
|
|
|
|