# Spawn Actor does not spawn an actor from a widget in C++

**URL:** <https://forums.unrealengine.com/t/spawn-actor-does-not-spawn-an-actor-from-a-widget-in-c/2689473>\
**Category:** C++\
**Tags:** unreal-engine, question\
**Created:** [January 4, 2026, 2:08am UTC](https://forums.unrealengine.com/t/spawn-actor-does-not-spawn-an-actor-from-a-widget-in-c/2689473 "2026-01-04T02:08:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AbdulVandamFBI](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AbdulVandamFBI](https://forums.unrealengine.com/u/AbdulVandamFBI)\
**Post date:** [January 4, 2026, 2:08am UTC](https://forums.unrealengine.com/t/spawn-actor-does-not-spawn-an-actor-from-a-widget-in-c/2689473/1 "2026-01-04T02:08:55Z")

</div>

Hi, I have a problem. I’m trying to spawn an actor from a widget for preview inside the widget. If I do it with the _Spawn Actor From Class_ node, everything is created perfectly. But in C++ there are problems: when I try to call spawn, the console says that the actor is created, but in fact there is nothing in the outliner. I can’t understand where it is being created. I’m a big beginner in C++, so it’s kind of like that. I read that you need to disable replication; in this situation it’s indeed not needed, but that still didn’t help.

I am using **Play As Client** and **Play As Listen Server**.

Here it is in text form:

```auto
APlayerController* PlayerController = GetOwningPlayer();

FActorSpawnParameters SpawnInfo;
SpawnInfo.Owner = PlayerController;
SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
SpawnInfo.bDeferConstruction = false;

if (PlayerController->IsLocalPlayerController())
{
    PreviewActor = GetOwningPlayerPawn()->GetWorld()->SpawnActor(
    APreviewItemActor::StaticClass(),
    FTransform::Identity,
    SpawnInfo
    );
    PreviewActor->SetReplicates(false);
}

```

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/a/c/eac15e28981caf9abf1da9d2ff5197e2861df4b7.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/c/d/fcdbe6f2da0d23d91699c8ee5ffacbc3f14a3b0e.png)

---

<div class="post-metadata">

**Author:** ![AbdulVandamFBI](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AbdulVandamFBI](https://forums.unrealengine.com/u/AbdulVandamFBI)\
**Post date:** [January 4, 2026, 3:06am UTC](https://forums.unrealengine.com/t/spawn-actor-does-not-spawn-an-actor-from-a-widget-in-c/2689473/2 "2026-01-04T03:06:52Z")

</div>

I found a solution for my case: I need to create an additional variable that will act as the class when spawning the actor.

> UPROPERTY(EditAnywhere, BlueprintReadWrite)  
> TSubclassOf PreviewActorClass;

It needs to be set in the Blueprint. After that, it is simply used as the class when spawning the actor:

> PreviewActor = GetOwningPlayerPawn()  
> -\>GetWorld()  
> -\>SpawnActor(  
> PreviewActorClass,  
> FTransform::Identity,  
> SpawnInfo  
> );

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/b/a/aba6a67feb235057513101d590b7dfeb1a6e9bc1.png)
