# USTRUCT referencing problem

**URL:** <https://forums.unrealengine.com/t/ustruct-referencing-problem/408519>\
**Category:** Editor Scripting\
**Tags:** Struct, compilation, ustruct, unreal-engine, question, CPP\
**Created:** [November 2, 2017, 12:27am UTC](https://forums.unrealengine.com/t/ustruct-referencing-problem/408519 "2017-11-02T00:27:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Crispy\_Penguin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Crispy\_Penguin](https://forums.unrealengine.com/u/Crispy_Penguin)\
**Post date:** [November 2, 2017, 12:27am UTC](https://forums.unrealengine.com/t/ustruct-referencing-problem/408519/1 "2017-11-02T00:27:41Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Nachtmahr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nachtmahr](https://forums.unrealengine.com/u/Nachtmahr)\
**Post date:** [November 2, 2017, 1:29am UTC](https://forums.unrealengine.com/t/ustruct-referencing-problem/408519/2 "2017-11-02T01:29:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Crispy\_Penguin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Crispy\_Penguin](https://forums.unrealengine.com/u/Crispy_Penguin)\
**Post date:** [November 2, 2017, 1:42am UTC](https://forums.unrealengine.com/t/ustruct-referencing-problem/408519/3 "2017-11-02T01:42:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Crispy\_Penguin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Crispy\_Penguin](https://forums.unrealengine.com/u/Crispy_Penguin)\
**Post date:** [November 2, 2017, 1:47am UTC](https://forums.unrealengine.com/t/ustruct-referencing-problem/408519/4 "2017-11-02T01:47:59Z")

</div>

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/d/9/fd971bde74a63afd4ec8028c322f60f4f41b2b96.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;
};
```

---

<div class="post-metadata">

**Author:** ![Nachtmahr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nachtmahr](https://forums.unrealengine.com/u/Nachtmahr)\
**Post date:** [November 2, 2017, 2:15am UTC](https://forums.unrealengine.com/t/ustruct-referencing-problem/408519/5 "2017-11-02T02:15:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Crispy\_Penguin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Crispy\_Penguin](https://forums.unrealengine.com/u/Crispy_Penguin)\
**Post date:** [November 2, 2017, 10:01am UTC](https://forums.unrealengine.com/t/ustruct-referencing-problem/408519/6 "2017-11-02T10:01:04Z")

</div>

Epic! Works like a charm, thank you good sir
