# AI Controller not attaching to a spawned character in UE 5

**URL:** <https://forums.unrealengine.com/t/ai-controller-not-attaching-to-a-spawned-character-in-ue-5/2161581>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [December 1, 2024, 2:57pm UTC](https://forums.unrealengine.com/t/ai-controller-not-attaching-to-a-spawned-character-in-ue-5/2161581 "2024-12-01T14:57:16Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jorgy\_M](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jorgy_m/32/88713_2.png) [@Jorgy\_M](https://forums.unrealengine.com/u/Jorgy_M)\
**Post date:** [December 1, 2024, 2:57pm UTC](https://forums.unrealengine.com/t/ai-controller-not-attaching-to-a-spawned-character-in-ue-5/2161581/1 "2024-12-01T14:57:16Z")

</div>

I’m facing an issue where my AI Controller does not attach to a character when I spawn it in the world using the `Spawn Actor from Class` node.

Here are the details:

1. The character has the correct **AI Controller Class** specified in its Class Defaults.
2. **Auto Possess AI** is set to **Placed in World or Spawned**.
3. When the character is manually placed in the level, everything works fine, and the AI Controller attaches as expected.
4. However, when I spawn the character dynamically, the `Get Controlled Pawn` node in the AI Controller returns `None`.

I also tried manually calling `Spawn Default Controller` after spawning the character, but it doesn’t seem to fix the issue. I know what AI Controller should be only one in to one actor…

What could be causing the AI Controller to fail to attach to the spawned character, and how can I fix this?

Any help or insights would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![steknika](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/steknika/32/974266_2.png) [@steknika](https://forums.unrealengine.com/u/steknika)\
**Post date:** [December 1, 2024, 7:08pm UTC](https://forums.unrealengine.com/t/ai-controller-not-attaching-to-a-spawned-character-in-ue-5/2161581/3 "2024-12-01T19:08:41Z")

</div>

@Jorgy_M  
Hey! When do you use `GetControlledPawn`?

I’m just guessing here, but maybe the AI Controller lifecycle and the character’s initialization gets out of sync when dynamically spawning actors. This is why it works when you manually add the character. Like everything is already running correctly in order.

So maybe the AI Controller might not initialize correctly if the character isn’t fully ready at the moment it spawns and while “Placed in World or Spawned” usually works, in some cases, spawning dynamically requires additional steps to ensure the controller properly attaches.

Maybe try this in blueprint (i’m not really familiar with BP):

```cpp
// Blueprint:
// After spawning the character
SpawnedCharacter->SpawnDefaultController();

```

You might need a slight delay to let the character finish its initialization. In Blueprint, use a `Delay` node (e.g., 0.1 seconds) before calling `SpawnDefaultController`.

Or make sure you override the `OnPosses` and call corresponding data from there, with a delegate or something that actually works for you.

```cpp
void AYourAIController::OnPossess(APawn* InPawn)
{
    Super::OnPossess(InPawn);

    // Your custom initialization code
    if (InPawn)
    {
        // Do something here
        UE_LOG(LogTemp, Warning, TEXT("AI Controller Possessed: %s"), *InPawn->GetName());
    }
}

```

So again, this is just a guessing, without seeing any actual code you made.

---

<div class="post-metadata">

**Author:** ![Jorgy\_M](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jorgy_m/32/88713_2.png) [@Jorgy\_M](https://forums.unrealengine.com/u/Jorgy_M)\
**Post date:** [December 1, 2024, 9:48pm UTC](https://forums.unrealengine.com/t/ai-controller-not-attaching-to-a-spawned-character-in-ue-5/2161581/4 "2024-12-01T21:48:22Z")

</div>

thank you helped Event on possess instead of begin play 😅

---

<div class="post-metadata">

**Author:** ![steknika](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/steknika/32/974266_2.png) [@steknika](https://forums.unrealengine.com/u/steknika)\
**Post date:** [December 1, 2024, 10:29pm UTC](https://forums.unrealengine.com/t/ai-controller-not-attaching-to-a-spawned-character-in-ue-5/2161581/5 "2024-12-01T22:29:36Z")

</div>

@Jorgy_M  
Sweet! Don’t forget to mark the answer as a solution! 🙂

---

<div class="post-metadata">

**Author:** ![Jorgy\_M](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jorgy_m/32/88713_2.png) [@Jorgy\_M](https://forums.unrealengine.com/u/Jorgy_M)\
**Post date:** [December 2, 2024, 8:52am UTC](https://forums.unrealengine.com/t/ai-controller-not-attaching-to-a-spawned-character-in-ue-5/2161581/6 "2024-12-02T08:52:57Z")

</div>

PM me please how to do that) here is no way to do this

---

<div class="post-metadata">

**Author:** ![steknika](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/steknika/32/974266_2.png) [@steknika](https://forums.unrealengine.com/u/steknika)\
**Post date:** [December 2, 2024, 12:12pm UTC](https://forums.unrealengine.com/t/ai-controller-not-attaching-to-a-spawned-character-in-ue-5/2161581/7 "2024-12-02T12:12:38Z")

</div>

@Jorgy_M  
You should see this in the bottom right corner on every comment, because you made the this topic:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/e/9/8e94d79d2d0369be5c1bf094146374565e8b89d8.png)

Press the `Solution` button on my comment which helped you.

---

<div class="post-metadata">

**Author:** ![Jorgy\_M](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jorgy_m/32/88713_2.png) [@Jorgy\_M](https://forums.unrealengine.com/u/Jorgy_M)\
**Post date:** [December 2, 2024, 1:21pm UTC](https://forums.unrealengine.com/t/ai-controller-not-attaching-to-a-spawned-character-in-ue-5/2161581/8 "2024-12-02T13:21:38Z")

</div>

I would see this if it were present here 😀

 ![Screenshot 2024-12-02 152038](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/e/a/6eaa100078e3beb0d2c11743bd8d654191072a2b.png)

---

<div class="post-metadata">

**Author:** ![steknika](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/steknika/32/974266_2.png) [@steknika](https://forums.unrealengine.com/u/steknika)\
**Post date:** [December 2, 2024, 4:06pm UTC](https://forums.unrealengine.com/t/ai-controller-not-attaching-to-a-spawned-character-in-ue-5/2161581/9 "2024-12-02T16:06:16Z")

</div>

@Jorgy_M

I don’t know why this is happening! But never mind then! 🙂 I’m happy that the issue is solved!

---

<div class="post-metadata">

**Author:** ![steknika](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/steknika/32/974266_2.png) [@steknika](https://forums.unrealengine.com/u/steknika)\
**Post date:** [December 3, 2024, 12:11pm UTC](https://forums.unrealengine.com/t/ai-controller-not-attaching-to-a-spawned-character-in-ue-5/2161581/10 "2024-12-03T12:11:11Z")

</div>

@Jorgy_M  
So basically, you didn’t set the category of this post as a Question. This is why you’re unable to add a Solution.

---

<div class="post-metadata">

**Author:** ![Jorgy\_M](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jorgy_m/32/88713_2.png) [@Jorgy\_M](https://forums.unrealengine.com/u/Jorgy_M)\
**Post date:** [December 3, 2024, 3:30pm UTC](https://forums.unrealengine.com/t/ai-controller-not-attaching-to-a-spawned-character-in-ue-5/2161581/11 "2024-12-03T15:30:05Z")

</div>

Probably, but thanks any way… Can you check my new topic please, probably you have good idea. Thank you

> [@Issue with Behavior Tree after AI Respawn](https://forums.unrealengine.com/t/issue-with-behavior-tree-after-ai-respawn/2165417):
>
> And Hello again))) I’m encountering an issue with my Behavior Tree in Unreal Engine 5. Here’s the situation: AI Respawn Setup: The AI character is destroyed and respawned multiple times during gameplay. Upon respawn, the Behavior Tree is restarted for the new AI instance. Problem: After the second respawn, the Behavior Tree seems to “freeze” or get stuck on a particular task (e.g., Wait or Move To). While the AI character is still moving and interacting correctly in the game world (e.g.…
