# \[Organizing My Code\] Where should Spawn functions be written?

**URL:** <https://forums.unrealengine.com/t/organizing-my-code-where-should-spawn-functions-be-written/32939>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [June 19, 2015, 2:34am UTC](https://forums.unrealengine.com/t/organizing-my-code-where-should-spawn-functions-be-written/32939 "2015-06-19T02:34:49Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![anonymous\_user\_f6530a3e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f6530a3e1](https://forums.unrealengine.com/u/anonymous_user_f6530a3e1)\
**Post date:** [June 19, 2015, 5:19am UTC](https://forums.unrealengine.com/t/organizing-my-code-where-should-spawn-functions-be-written/32939/4 "2015-06-19T05:19:26Z")

</div>

The standard way to find an actor is to basically go through all actors of a certain class using the actor iterator until you find the one you want:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

From the wiki:

```auto

void AYourControllerClass::PrintAllStaticMeshActorsLocations()
{
	//EngineUtils.h
	for (TActorIterator<AStaticMeshActor> ActorItr(GetWorld()); ActorItr; ++ActorItr)
	{
		ClientMessage(ActorItr->GetName());
		ClientMessage(ActorItr->GetActorLocation().ToString());
	}
}

```

Just replace AStaticMeshActor with your custom class.

---

_[View the full topic](https://forums.unrealengine.com/t/organizing-my-code-where-should-spawn-functions-be-written/32939)._
