I was working in the Unreal Udemy course, in the lecture “Using DrawDebugLine” and unreal keeps crashing, I have no idea why and I need help.
Here is the crash report:
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00007ff842c80008
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_Core
UE4Editor_Core
UE4Editor_Core
UE4Editor_Core
UE4Editor_Core
kernel32
ntdll
Here is my cpp file:
#define OUT
#include "GameFramework/PlayerController.h"
#include "Engine/World.h"
#include "DrawDebugHelpers.h"
#include "MyGrabber.h"
// Sets default values for this component's properties
UMyGrabber::UMyGrabber()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
// Called when the game starts
void UMyGrabber::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void UMyGrabber::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
FVector PlayerViewPointLocation;
FRotator PlayerViewPointRotation;
GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(
OUT PlayerViewPointLocation,
OUT PlayerViewPointRotation
);
FVector LineTraceEnd = PlayerViewPointLocation + PlayerViewPointRotation.Vector() * Reach;
DrawDebugLine(
GetWorld(),
PlayerViewPointLocation,
LineTraceEnd,
FColor(0, 255, 0),
false,
0.f,
0,
5.f
);
}
And here is my header:
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "MyGrabber.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILD_ESCAPE_API UMyGrabber : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UMyGrabber();
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
private:
float Reach = 100.f;
};
Thanks in advance