# Can someone show my how to use FInstancedStruct please

**URL:** <https://forums.unrealengine.com/t/can-someone-show-my-how-to-use-finstancedstruct-please/1898788>\
**Category:** C++\
**Tags:** unreal-engine, question\
**Created:** [June 11, 2024, 9:49am UTC](https://forums.unrealengine.com/t/can-someone-show-my-how-to-use-finstancedstruct-please/1898788 "2024-06-11T09:49:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [June 11, 2024, 9:49am UTC](https://forums.unrealengine.com/t/can-someone-show-my-how-to-use-finstancedstruct-please/1898788/1 "2024-06-11T09:49:19Z")

</div>

i’ve been trying in c++ but it doesn’t seem to be recognized, although i think my Visual Studios is bugged because it also doesnt recognize GENERATED\_BODY anymore when it did earlier with no changes.

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [June 13, 2024, 3:54am UTC](https://forums.unrealengine.com/t/can-someone-show-my-how-to-use-finstancedstruct-please/1898788/2 "2024-06-13T03:54:44Z")

</div>

is no one using this?  
its a new feature so not much documentation but seems extremely powerful

---

<div class="post-metadata">

**Author:** ![zeaf](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zeaf/32/1108035_2.png) [@zeaf](https://forums.unrealengine.com/u/zeaf)\
**Post date:** [June 13, 2024, 7:58pm UTC](https://forums.unrealengine.com/t/can-someone-show-my-how-to-use-finstancedstruct-please/1898788/3 "2024-06-13T19:58:10Z")

</div>

FInstancedStruct is just a wrapper of a struct type and data that points to a struct of that type

In C++, you can easily use it like so:

```auto
// Create a new instanced struct that contains a vector
FInstancedStruct TestStruct = FInstancedStruct::Make(FVector::UpVector);

// Read an instanced struct as a vector, if you are 100% sure it contains a vector
const FVector& TestVector = TestStruct.Get<FVector>();

// Test if an instanced struct is a vector
if (const FVector* TestVector = TestStruct.GetPtr<FVector>())
{
   // It contains a vector
}

// This would fail in this example, since Test contains an FVector
if (const FVector* TestVector = TestStruct.GetPtr<FRotator>())
{
   // Would not go in here
}

// You can also use the mutable versions if you want to modify the content in the instanced struct
Test.GetMutablePtr<FVector>();
Test.GetMutable<FVector>();

```

For Blueprints, you can define an instanced struct like so:

```auto
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FInstancedStruct MyInstancedStruct;

```

You can use the `BaseStruct` meta specifier to limit the drop down menu in the editor, for example:

```auto
USTRUCT(BlueprintType)
struct FMyStruct
{
   GENERATED_BODY()

   UPROPERTY(EditAnywhere, BlueprintReadWrite)
   int MyInt = 0;
}

// This will show a drop down in the editor, containing only MyStruct and its children structs
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BaseStruct = "/Script/MyModule.MyStruct"))
FInstancedStruct MyInstancedStruct;

```

There are blueprint functions as well to handle instanced structs:  
SetInstancedStructValue and GetInstancedStructValue

Those will have a wildcard pin, to which you can connect a Break or Make struct nodes (or any other struct properties from other nodes). The GetInstancedStructValue node has 2 execution paths, for success and failure. If the passed Instanced struct is not of the connected struct type, then the Fail path will be executed

You can use Instanced structs as function parameters as well if you wish, and convert the struct to your expected type inside the function

Instanced structs also support replication out of the box

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [June 14, 2024, 2:29am UTC](https://forums.unrealengine.com/t/can-someone-show-my-how-to-use-finstancedstruct-please/1898788/4 "2024-06-14T02:29:08Z")

</div>

thanks, when i did it, it kept saying FInstancedStruct was an unknown type i had included instancedstruct.h am i missing anything else?

---

<div class="post-metadata">

**Author:** ![zeaf](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zeaf/32/1108035_2.png) [@zeaf](https://forums.unrealengine.com/u/zeaf)\
**Post date:** [June 14, 2024, 8:13am UTC](https://forums.unrealengine.com/t/can-someone-show-my-how-to-use-finstancedstruct-please/1898788/5 "2024-06-14T08:13:46Z")

</div>

You need to add StructUtils to your build.cs file and include InstancedStruct.h wherever you use instanced structs, but that should be all

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [June 15, 2024, 6:09am UTC](https://forums.unrealengine.com/t/can-someone-show-my-how-to-use-finstancedstruct-please/1898788/6 "2024-06-15T06:09:27Z")

</div>

thanks for your help, got it working, had to include StructUtils.h and InstancedStruct.h

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [July 15, 2024, 6:09am UTC](https://forums.unrealengine.com/t/can-someone-show-my-how-to-use-finstancedstruct-please/1898788/7 "2024-07-15T06:09:40Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
