# Field becomes nullptr when comes out of function space

**URL:** <https://forums.unrealengine.com/t/field-becomes-nullptr-when-comes-out-of-function-space/479260>\
**Category:** C++\
**Tags:** unreal-engine, CPP, question, pointers\
**Created:** [February 23, 2021, 8:45am UTC](https://forums.unrealengine.com/t/field-becomes-nullptr-when-comes-out-of-function-space/479260 "2021-02-23T08:45:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cybeaster](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Cybeaster](https://forums.unrealengine.com/u/Cybeaster)\
**Post date:** [February 23, 2021, 8:45am UTC](https://forums.unrealengine.com/t/field-becomes-nullptr-when-comes-out-of-function-space/479260/1 "2021-02-23T08:45:17Z")

</div>

I have a field in class that stores a references to objects and I have a function with 2 methods in it.  
I pass 2 null pointers to the first function to assign values to them, and after I pass these pointers to second function.  
The problem is that after completion of the first function these members become nullptr, and I pass nullptr to the second function.  
[http://joxi.ru/VrwkBelT4zRObr](http://joxi.ru/VrwkBelT4zRObr) - main function  
[Joxi (205 kb) закачан 23 февраля 2021 г. Joxi](http://joxi.ru/5mdDOnMi85Oklm) -the first function  
[Joxi (251 kb) закачан 23 февраля 2021 г. Joxi](http://joxi.ru/KAx1vM9fKQEMkr) - the second function  
[Joxi (170 kb) закачан 23 февраля 2021 г. Joxi](http://joxi.ru/MAj6yelCkGgj1A) - Struct with refs

---

<div class="post-metadata">

**Author:** ![Firefly74](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Firefly74](https://forums.unrealengine.com/u/Firefly74)\
**Post date:** [February 23, 2021, 1:53pm UTC](https://forums.unrealengine.com/t/field-becomes-nullptr-when-comes-out-of-function-space/479260/2 "2021-02-23T13:53:01Z")

</div>

Hey, one of the screenshot isn’t working  
not sure but looks like you have a function parameter named the same as an object variable, in these cases, better use an other name to avoid mistakes  
also, use some breakpoints, especially in your spawn model picker  
check that the rowmodelpickerclass isn’t null  
check that the create widget actually return a value
