Help Crashing UE_LOG

Hello I am an avid Unity user with ok C# skills and have begun learning C++, I am somewhat comfortable with most of C++ syntax as its the father of C# but im still having issues.

I’m trying to get my Unreal C++ feet wet by testing simple things id easily do in unity, things like getting references,setting variables and doing a simple log to get familiar with Unreal error debugging.

It seems im doing something that’s crashing the project as i try to play test my debug log.

I’ve been going through the many possibilities of fixes or solutions but im coming up short with my own testing.

Can anyone point me in a direction for me to debug this debug Log?

#include “Test415CPP.h”
#include “MyActor.h”
#include “MyActor2.h”
// Sets default values
AMyActor::AMyActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
PrimaryActorTick.bCanEverTick = true;
inputBind.ActionName = inputBindName;
}

// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
	Super::BeginPlay();
	ActorTransform = GetActorTransform();
	
	test->Go(ActorRotation);

	UE_LOG(LogTemp,Log,TEXT("Input name %s"),*inputBind.ActionName.ToString());
}

// Called every frame
void AMyActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "GameFramework/Actor.h"
#include "MyActor2.h"
#include "MyActor.generated.h"


UCLASS()
class TEST415CPP_API AMyActor : public AActor
{
	GENERATED_BODY()

public:
	// Sets default values for this actor's properties
		AMyActor();
	UPROPERTY(EditAnywhere, Category = "Object Transform Properties")
		FTransform ActorTransform;
	UPROPERTY(EditAnywhere, Category = "Object Transform Properties")
		FVector ActorRotation;
	UPROPERTY(EditAnywhere, Category = " Class Reference ")
		AMyActor2* test;
	UPROPERTY(EditAnywhere, Category = " Input Binding ")
		FInputActionKeyMapping inputBind;
	UPROPERTY(EditAnywhere, Category = " Input Binding ")
		FKey testKey;
	UPROPERTY(EditAnywhere, Category = " Input Binding ")
		FName inputBindName;
	

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:
	// Called every frame
	virtual void Tick(float DeltaTime) override;

Have you tried moving

inputBind.ActionName = inputBindName;

to BeginPlay() ?

Yes i have ,but it still results in a crash. it says its an an access violation - code c0000005. upon reading more into it it claims that input bind is a null pointer. which i get but if i only want access to the one thing i did initialize why do i need to fill in all of the struct variables?

I think it’s because you haven’t initialized inputBind yet. I think you need to call the constructor!
Try something like
FInputActionKeyMapping KeyMap = FInputActionKeyMapping(“jump”, FKey(“C”));

this looks like a promising answer i will check it when i’m home

Ive tried and failed it seems that that may not be the solution but possibly part of it? i added it to the code as well as removing my link to my AMyActor2 script.
AMyActor2 test->Go was causing the crash for sure which is odd because i managed to get it to work properly before but it was looking at null in my later test.

i redid my code a bit but my UE_LOG Still cant make sense of this.

// Fill out your copyright notice in the Description page of Project Settings.

#include "Test415CPP.h"
#include "MyActor2.h"
#include "MyActor.h"

// Sets default values
AMyActor::AMyActor()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	inputBind = FInputActionKeyMapping("jump",FKey("C"));
	inputBindName = FName();
}

// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
	Super::BeginPlay();
	inputBind.ActionName = inputBindName;
	ActorTransform = GetActorTransform();
	UE_LOG(LogTemp, Warning, TEXT("InputbindName %s"),inputBind.ActionName.ToString());
	//test->Go(ActorRotation);
}

// Called every frame
void AMyActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
}

so i get that FName needs to be a pointer* in order to work as *inputBindName.ToString(); works but this doesnt seem possible with FInputActionKeyMapping.ActionName.ToString();

ok so apparently i can do*FInputActionKeyMapping.ActionName.ToString(); and it will return None. this mean its logging but its not logging how i expected. its giving None as its String instead of what i wrote in InputBindName in the details Panel or even what InputBind already has listed.

the answers lies in putting *FInputActionKeyMapping.ActionName.ToString(); in Begin Play();

as well as setting FinputActionKeyMapping.ActionName = FName() in BeginPlay to actually Visualize Changes.

Thanks ndelchen for being the first to help especially as quickly as you did , your awesome.

Put them in BeginPlay(); thats when changes can be visualized in logs as well as in details panel of editor and *FInputActionKeyMapping.ActionName.ToString(); To Log it.

// Fill out your copyright notice in the Description page of Project Settings.

#include "Test415CPP.h"
#include "MyActor2.h"
#include "MyActor.h"

// Sets default values
AMyActor::AMyActor()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	inputBind = FInputActionKeyMapping("jump",FKey("C"));
	
}

// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
	Super::BeginPlay();
	inputBindName = FName("Working");
	inputBind.ActionName = inputBindName;
	ActorTransform = GetActorTransform();
	UE_LOG(LogTemp, Warning, TEXT("InputbindName %s"),*inputBind.ActionName.ToString());
	//test->Go(ActorRotation);
}

// Called every frame
void AMyActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
}

i guess the test code was really causing it to crash as even after recompile this still works;

// Fill out your copyright notice in the Description page of Project Settings.

#include "Test415CPP.h"
#include "MyActor2.h"
#include "MyActor.h"

// Sets default values
AMyActor::AMyActor()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
}

// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
	Super::BeginPlay();
	
	inputBind.ActionName = inputBindName;
	ActorTransform = GetActorTransform();
	UE_LOG(LogTemp, Warning, TEXT("InputbindName %s"),*inputBind.ActionName.ToString());

}

// Called every frame
void AMyActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
}

I’m glad you solved your issue :slight_smile: Keep it up!