# Changing AI controller for actor?

**URL:** <https://forums.unrealengine.com/t/changing-ai-controller-for-actor/747283>\
**Category:** International\
**Tags:** aicontroller, unreal-engine, question, Blueprint\
**Created:** [January 11, 2023, 7:22pm UTC](https://forums.unrealengine.com/t/changing-ai-controller-for-actor/747283 "2023-01-11T19:22:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xvixicho](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Xvixicho](https://forums.unrealengine.com/u/Xvixicho)\
**Post date:** [January 11, 2023, 7:22pm UTC](https://forums.unrealengine.com/t/changing-ai-controller-for-actor/747283/1 "2023-01-11T19:22:32Z")

</div>

Hello everyone!

So I am doing this small NPC project, where I need to change the AI controller of NPC.

I used “Set AI Controller” to set it on “Event BeginPlay” and spawned the default controller, but that doesn’t work when I try to change it…

This is how my code looks for setting the AI controller for the first time :

![set_controller_deer_child](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/0/1/2013d8d83bb9d0610589ae8279e2c644517a8588.png)

And this is when I try to change it:

![set_controller_deer_male](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/b/0/8b0208399e4c8c48b7eec08fec02c905188e85bd.png)

I read on Reddit that “Controller controls Actor” and not vice versa, but I feel like this could be done. I mean to change the controller…

Hopefully, I can get the answer…

Thanks In advance!

---

<div class="post-metadata">

**Author:** ![user\_goodman011](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@user\_goodman011](https://forums.unrealengine.com/u/user_goodman011)\
**Post date:** [January 11, 2023, 8:37pm UTC](https://forums.unrealengine.com/t/changing-ai-controller-for-actor/747283/2 "2023-01-11T20:37:03Z")

</div>

Hi 😀 So my solution is this: in your possessed pawn blueprint destroy your current ai controller, then spawn a new one and possess your pawn. The issue with ai controllers is that you could not destoy them in blueprints by destoyActor node, so the work around is to use SetLifeSpan with a small duration( you could read the discussion here [Ai controller can never be destroyed or be garbaged collected - #16 by acatalept](https://forums.unrealengine.com/t/ai-controller-can-never-be-destroyed-or-be-garbaged-collected/383732/16)). The way I would solve your problem is this:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/3/1/031970e79ac83f1af7b93a02465e61f632427bb1.png)  
Hope this helps

---

<div class="post-metadata">

**Author:** ![Xvixicho](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Xvixicho](https://forums.unrealengine.com/u/Xvixicho)\
**Post date:** [January 11, 2023, 8:52pm UTC](https://forums.unrealengine.com/t/changing-ai-controller-for-actor/747283/3 "2023-01-11T20:52:37Z")

</div>

Hi! Thanks for helping me once again! I get the logic of this thing, I just didn’t know these functions, thanks for telling me about those two functions.

Aside from that, I am getting this weird error, I tried re-doing this sequence of a blueprint a few times, but I can’t quite help it. Any idea about it?

Thanks in advance!

Edit: oops forgot to attach a photo xd

 ![error_shown](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/2/f/12fea9b313fbe4c97bdb250928f38366f7de5cff.png)

EDIT N2: Oh I’m so stupid, I forgot to attach the Transform, now it works like a charm! Thanks a lot!
