# \[Verse\] Struct custom constructor for instantiation?

**URL:** <https://forums.unrealengine.com/t/verse-struct-custom-constructor-for-instantiation/1637535>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [January 23, 2024, 8:34pm UTC](https://forums.unrealengine.com/t/verse-struct-custom-constructor-for-instantiation/1637535 "2024-01-23T20:34:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![atanknomore](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@atanknomore](https://forums.unrealengine.com/u/atanknomore)\
**Post date:** [January 23, 2024, 8:34pm UTC](https://forums.unrealengine.com/t/verse-struct-custom-constructor-for-instantiation/1637535/1 "2024-01-23T20:34:06Z")

</div>

is there no way for structs to have custom constructors? I have a struct that has a bunch of integers and I’d like to be able to change the value of one of the properties.

With verse structs cannot have functions but it also tells me that doing any `set` on its members is not allowed as structs do not allow `var` . Does anyone know if there’s syntax to at least make a custom ctor? Initialize list doesn’t seem to work either

this is my struct

```auto
my_player_struct := struct<concrete>() 
{
    Player : ?player = false

    LivesLeft : int = 3

    CurrentInstanceActive : int = -1

}

```

doing `my_player_struct { option{APlayerObject}, 42, 0 }` doesn’t work , so I’m wondering if I have any options here. Doing it via () doesn’t work either as it says it’s not compatible with tuple

and docs say constructor is for class only, so not really sure if/how we’re supposed to work with struct data changing. I understand immutability - this is for an array and have no issues recreating the array after the change I just want to be able to have structs with different values besides their defaults changed at runtime, not via `@editable`

---

<div class="post-metadata">

**Author:** ![atanknomore](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@atanknomore](https://forums.unrealengine.com/u/atanknomore)\
**Post date:** [January 23, 2024, 8:47pm UTC](https://forums.unrealengine.com/t/verse-struct-custom-constructor-for-instantiation/1637535/2 "2024-01-23T20:47:19Z")

</div>

The solution is that the constructor needs to have the param names included in it, like so:

`my_player_struct { Player := option{APlayerValue}, LivesLeft := 42, CurrentInstanceActive := 0 }`

---

<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:** [February 22, 2024, 8:48pm UTC](https://forums.unrealengine.com/t/verse-struct-custom-constructor-for-instantiation/1637535/3 "2024-02-22T20:48:00Z")

</div>

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