Produktion_Digitaler_Medien/Source/BuildingEscape/Grabber.h

51 lines
1.3 KiB
C++

// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "PhysicsEngine/PhysicsHandleComponent.h"
#include "Grabber.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDINGESCAPE_API UGrabber : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UGrabber();
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
protected:
// Called when the game starts
virtual void BeginPlay() override;
private:
UPROPERTY(EditAnywhere)
float Reach = 100.f;
UPROPERTY() //Everything with a U has a UPROPERTY
UPhysicsHandleComponent* PhysicsHandle = nullptr; //protection against crashes
UPROPERTY()
UInputComponent* InputComponent = nullptr;
void Grab();
void GrabRelease();
void FindPhysicsHandle();
void SetupInputComponent();
//return the first Actor in Reach with physicsbody
FHitResult GetFirstPhysicsBodyInReach() const;
//Return Players Line Trace End
FVector GetLineTraceEnd() const; // playersReach
//Get Players Position in the World
FVector GetPlayerWorldPosition() const;
};