#pragma region
// #pragma once
//
// #include "CoreMinimal.h"
// #include "PhysicsEngine/PhysicsHandleComponent.h"
// #include "Grabber.generated.h"
//
// UCLASS(ClassGroup=(Custom),meta=(BlueprintSpawnableComponent))
// class BUILDINGESCAPE_API UGrabber : public UActorComponent
// {
// GENERATED_BODY()
//
// public:
// UGrabber();
//
// protected:
// virtual void BeginPlay() override;
//
// public:
// virtual void TickComponent(float DeltaTime,ELevelTick TickType,FActorComponentTickFunction* ThisTickFunction) override;
//
// private:
//
// FVector PlayerViewPointLocation;
// FVector LineTraceEnd;
// FRotator PlayerViewPointRotation;
//
//
// const float Reach = 100;
// UPhysicsHandleComponent* PhysicsHandle = nullptr;
// UInputComponent* InputComponent = nullptr;
//
// void Grab();
// void Release();
//
// void FindPhysicsHandle();
// void SetupInputComponent();
//
// //return first actor within reach
// FHitResult GetFirstPhysicsBodyInReach() ;
// FVector GetLineTraceEnd() ;
// };
#pragma endregion MyCode header file
#pragma region
#pragma once
#include "CoreMinimal.h"
#include "PhysicsEngine/PhysicsHandleComponent.h"
#include "Grabber.generated.h"
UCLASS(ClassGroup=(Custom),meta=(BlueprintSpawnableComponent))
class BUILDINGESCAPE_API UGrabber : public UActorComponent
{
GENERATED_BODY()
public:
UGrabber();
virtual void TickComponent(float DeltaTime,ELevelTick TickType,FActorComponentTickFunction* ThisTickFunction) override;
protected:
virtual void BeginPlay() override;
private:
const float Reach = 100;
UPhysicsHandleComponent* PhysicsHandle = nullptr;
UInputComponent* InputComponent = nullptr;
void Grab();
void Release();
void FindPhysicsHandle();
void SetupInputComponent();
//return first actor within reach
FHitResult GetFirstPhysicsBodyInReach() const ;
FVector GetPlayerReach() const;
FVector GetPlayerWorldPosition() const;
};
#pragma endregion GameDevTV's Code