# Why when I use the spawn actor do I need it to run twice? augmented reality

**URL:** <https://forums.unrealengine.com/t/why-when-i-use-the-spawn-actor-do-i-need-it-to-run-twice-augmented-reality/835810>\
**Category:** Feedback & Requests\
**Tags:** unreal-engine, Android, Augmented-Reality, Blueprint, question\
**Created:** [March 31, 2023, 3:31pm UTC](https://forums.unrealengine.com/t/why-when-i-use-the-spawn-actor-do-i-need-it-to-run-twice-augmented-reality/835810 "2023-03-31T15:31:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![JasonMoretti](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JasonMoretti](https://forums.unrealengine.com/u/JasonMoretti)\
**Post date:** [March 31, 2023, 3:31pm UTC](https://forums.unrealengine.com/t/why-when-i-use-the-spawn-actor-do-i-need-it-to-run-twice-augmented-reality/835810/1 "2023-03-31T15:31:53Z")

</div>

Hi Everyone.  
I have a query about augmented reality and the spawn actor node

 ![K2Node_Composite_10-Buscar Imagenes, Spawn y asignar interacciones con actor](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/d/9/4d9d437bc1fd09396c7fbd63e961acabd5da246e.jpeg)

If the spawn actor node is executed only once with the position references of the recognized image, the actor does not appear, it needs to be executed at least 2 times (I had to validate the actor so that the Spawn event would stop when it already existed in the world ), I don’t know if it does it to set the internal variables or what is the logic behind it, however I would like to know what is the reason for this behavior.

Thank you very much in advance and have a good evening.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [March 31, 2023, 3:38pm UTC](https://forums.unrealengine.com/t/why-when-i-use-the-spawn-actor-do-i-need-it-to-run-twice-augmented-reality/835810/2 "2023-03-31T15:38:58Z")

</div>

It’s too small to read, really, but I think you make the spawn call here?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/b/b/bbb1ee25254d9b4207af6ef30eb8dc7495427b25.jpeg)

By that time, these values

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/a/b/dab18a8905e024baeef435f631aaa7cc046e435b.jpeg)

will always be from the end of the array, because you have finished loop by now.

---

<div class="post-metadata">

**Author:** ![JasonMoretti](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JasonMoretti](https://forums.unrealengine.com/u/JasonMoretti)\
**Post date:** [March 31, 2023, 5:14pm UTC](https://forums.unrealengine.com/t/why-when-i-use-the-spawn-actor-do-i-need-it-to-run-twice-augmented-reality/835810/3 "2023-03-31T17:14:36Z")

</div>

I tried to modify the find variable before the event was called so that the actor could be generated only with an execution of the SpawnActor node, however the only way that works for me is to check the validity of the actor and then limit the Spawn event with the branch.

 ![K2Node_Composite_10-Buscar Imagenes, Spawn y asignar interacciones con actor_0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/d/e/7def878720c2a3c9446102485058fc7e3906acf5.jpeg)

there the SpawnActor node is executed only once, but the actor cannot be created in the world.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [March 31, 2023, 5:42pm UTC](https://forums.unrealengine.com/t/why-when-i-use-the-spawn-actor-do-i-need-it-to-run-twice-augmented-reality/835810/4 "2023-03-31T17:42:09Z")

</div>

Sorry, it’s so small, almost impossible to read.

Are you trying to spawn one of each class?

Then you need the spawn call in the loop.

---

<div class="post-metadata">

**Author:** ![JasonMoretti](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JasonMoretti](https://forums.unrealengine.com/u/JasonMoretti)\
**Post date:** [March 31, 2023, 6:22pm UTC](https://forums.unrealengine.com/t/why-when-i-use-the-spawn-actor-do-i-need-it-to-run-twice-augmented-reality/835810/5 "2023-03-31T18:22:45Z")

</div>

I’m sorry, I have attached slightly larger images.

 ![Imagen 1 modo 1.PNG](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/6/6/96637cb9ae3b8bea22f87a5caff85c04a519b361.jpeg)  
 ![Imagen 2modo 1.PNG](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/3/c/c3c781f4946d9278716ffbdf858bef50c7c81215.jpeg)

This is the first mode, where everything works perfectly, only I’m intrigued that the SpawnActor node needs to be executed more than once for the actor to be created.

 ![Imagen 1 modo 2.PNG](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/b/a/0ba7903a04560d2c6358e36555729d1874ccd014.jpeg)

 ![Imagen 2 modo 2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/b/9/9b9573b599b564e3562561cc8e042578bbb7aace.png)  
This is the second way, where I try to make it run only once but the actor is not created when recognizing the image.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [March 31, 2023, 6:55pm UTC](https://forums.unrealengine.com/t/why-when-i-use-the-spawn-actor-do-i-need-it-to-run-twice-augmented-reality/835810/6 "2023-03-31T18:55:18Z")

</div>

It’s on tick (!)

It’s like calling that spawn event, on every frame ( 120 times per second ), with the last class from your map.

I’m really not sure what the meaning of that is.

---

<div class="post-metadata">

**Author:** ![JasonMoretti](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JasonMoretti](https://forums.unrealengine.com/u/JasonMoretti)\
**Post date:** [March 31, 2023, 7:18pm UTC](https://forums.unrealengine.com/t/why-when-i-use-the-spawn-actor-do-i-need-it-to-run-twice-augmented-reality/835810/7 "2023-03-31T19:18:21Z")

</div>

If I had to leave the “Get All AR Geometries By Class” node in the event tick because it didn’t work for me outside of there.
