Crash at play

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

Are you using Play In Editor or Simulate?
image

I am using play in editor

Could you try a rebuild?

In VS Code and with Unreal closed do the following:

Ctrl + Shift + B > ProjectNameEditor Platform Development Rebuild

Where ProjectName is the name of your project and Platform is the platform you’re targeting e.g. Win64

Unfortunately, it did not work, it keeps crashing when I hit play.

In that case would you mind sending me your project using the following link?

https://gdev.tv/projectupload

Please use File > Package Project > Zip Up Project within Unreal as this will ensure only required files are zipped up and things like the Binaries are excluded.

Done

Wait, nevermind it works now.

Wait, it worked once and then it crashed.

Seems fine on my end. Could you post the crash log the next time it happens?

Privacy & Terms