# How in function declare "Object Reference" return?

**URL:** <https://forums.unrealengine.com/t/how-in-function-declare-object-reference-return/683233>\
**Category:** C++\
**Tags:** unreal-engine, UE5-0, UE4, UE4-27, question, CPP\
**Created:** [November 3, 2022, 12:00pm UTC](https://forums.unrealengine.com/t/how-in-function-declare-object-reference-return/683233 "2022-11-03T12:00:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Em\_Ce92](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Em\_Ce92](https://forums.unrealengine.com/u/Em_Ce92)\
**Post date:** [November 3, 2022, 12:00pm UTC](https://forums.unrealengine.com/t/how-in-function-declare-object-reference-return/683233/1 "2022-11-03T12:00:29Z")

</div>

Hi, I have been studying for a short time in C ++ and I encountered a problem that I cannot find a clear answer to on the internet.

The problem as in the title of the post is quite simple. When creating a new function, at the beginning we declare what type of “Return” will be and if everything is understandable to me, when I want to declare any other type, everything works as it should. But there is no way I can declare the Return “Object Reference” as for example has the “Spawn Actor From Class” function as in the picture below.

 ![Spawn Actor From Class](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/0/5/e05f4d3d7fb80e45c917478aed88a77af642978b.png)

Here is an example of a function with different “Return” types that I have successfully declared:

Function with Int Return :

 ![Int C++](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/2/9/c298fa466b17395261b72bec55e453275340b289.png)

 ![Int Return](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/8/0/1805bfec7bffbc16c519c60ddf40e2e99be996f7.png)

Function with Array Return :

 ![Array C++](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/3/3/c33f3821158aac62fa9e26686020665db0d90132.png)

 ![Array Return](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/4/4/044da13b0496ce3d34e6f6d100b967a6f3f5c33f.png)

Function with Soft Object Reference Return :

 ![C++ Soft Object](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/8/0/980b18a3d57fcdbcc749c97d12a5da96ee1247d2.png)

 ![Soft Object Reference](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/7/7/d7700af7b9119a15cf751bfa7e7399ae9abc8f19.png)

I tried to look at the node made in Unreal but unfortunately I do not fully understand how they are declared.

Thanks for any tips!

---

<div class="post-metadata">

**Author:** ![UnrealVerseGuru](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@UnrealVerseGuru](https://forums.unrealengine.com/u/UnrealVerseGuru)\
**Post date:** [November 3, 2022, 12:43pm UTC](https://forums.unrealengine.com/t/how-in-function-declare-object-reference-return/683233/2 "2022-11-03T12:43:45Z")

</div>

o/  
You just declare return type as UObject\*  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/4/4/644b1c92c7c31e9fa0e2bd5b104e4c94a5c99df0.png)

Keep in mind inheritance. Objects like AActors are inheriting from UObject hence you get Return Actor object pin type.

---

<div class="post-metadata">

**Author:** ![Em\_Ce92](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Em\_Ce92](https://forums.unrealengine.com/u/Em_Ce92)\
**Post date:** [November 3, 2022, 3:07pm UTC](https://forums.unrealengine.com/t/how-in-function-declare-object-reference-return/683233/3 "2022-11-03T15:07:21Z")

</div>

Thank you very much! I appreciate you helping me. Everything works great. Thanks again!
