USTRUCT referencing problem

Here are some cheap karma points for taking.

I am converting a prototype from blueprint to C++ where I get into situation, where my USTRUCT S is holding reference to class A, but my class A has to have array of structs S.

Typical cyclic dependency issue, but it was possible in Blueprint structs, so I hope there is a way to do it in C++ structs as well.

I would normally put class A; but that results in ustruct not being editable in editor.

Any thoughts? Help?

Can you screengrab your Prototype BP Struct an maybe Pastebin your Code so far?

Sure, here is the “goal” - I want to have grid of points and each point knows about other nearby points. Aka nodes and edges. This is the way it looks in the world using BP struct (without an issue) ![alt text]

This point knows about 2 other points1
Code will be in another post

As requested, this is the code for my C++ try -
But in editor, usage of that USTRUCT results in array of “members” and it does not actually give the right boxes to fill.

218755-cpppoints.png

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"

#include "PlatformBox.generated.h"

class APlatformBox;

UENUM(BlueprintType)
enum class E_CPathType : uint8
{
	Walk					UMETA(DisplayName = "Walk"),
	Jump					UMETA(DisplayName = "Jump"),

};


USTRUCT(BlueprintType)
struct FPathBetweenNodes
{
	GENERATED_BODY()
public:

	UPROPERTY(BlueprintReadWrite)
		APlatformBox* connectedPoint;
	UPROPERTY(BlueprintReadWrite)
		int32 weight;
	UPROPERTY(BlueprintReadWrite)
		E_CPathType PathType;
	UPROPERTY(BlueprintReadWrite)
		FVector jumpVelocity;

};


UCLASS()
class TEDDYPROJECT_API APlatformBox : public AActor
{
	GENERATED_BODY()
	
public:	
	APlatformBox();

protected:
	virtual void BeginPlay() override;

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

	
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		int32 id = 0;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		TArray<FPathBetweenNodes> connections;
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		bool showConnections;
};

USTRUCT(BlueprintType)
struct FPathBetweenNodes
{
GENERATED_BODY()
public:

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Something")
		class APlatformBox* connectedPoint;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Something")
		int32 weight;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Something")
		E_CPathType PathType;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Something")
		FVector jumpVelocity;

	FPathBetweenNodes() {
		connectedPoint = nullptr;
		weight = 0;
		PathType = E_CPathType::Jump;
		jumpVelocity = FVector::ZeroVector;
	}

};

EditAnywhere should fix your issue. I forward declared inside the struct but it should work like you hav it now too. Aside from that always try to add a Constructur to your Struct with initial Values =) its good Practice todo so.

Epic! Works like a charm, thank you good sir