Download

Problem with switching controllers

Hello everyone!

I resolved myself to come here since google could not help me. SO little bit of context: Have a two characters, that the player can switch between. The blueprint for that is in the level blueprint. Now I want the drone to follow the player when he is not possessed, and it works at first, but as soon as it gets possessed and un-possessed, nothing work anymore, I get an error saying the GetController returned a NULL.

I know Unreal is probably the worst engine to learn from scratch, but I decided to go trough with it and now I am stuck. Maybe this is a very dumb question, but please help a noob.

The PlayerController is always tied to the actual player.
I recommend that you implement “switch which character is controlled” in the PlayerController, not the level blueprint.

What does “possession check” do? Does the player ever possess the drone? If so, the AI controller will be detached from the drone when you do – only one controller can be attached to a given pawn at once, and a controller can only be attached to one pawn at a time, and both “ai controllers” and “player controllers” are kinds of “controllers.”

I probably badly explained. The player control both the human character, and the drone. He can switch between the two. I have no problem switching to and form the drone, but I want the droen to follow the human when he is not being controlled, which does not work on I unpossess him. The switch is handled in the level blueprint here

Yes. When you unpossess the drone, the AI Controller that would auto-pilot the drone will not auto-possess the drone – you need to hook that up yourself if you want the drone to have a controller when the player doesn’t control it.

Note that, when a pawn first spawns in the level, it may have an “auto possess AI controller” configured. This only works when it first starts playing – not each time it loses a controller.

oh, I see. I will try it tonight and come back to you

Was not able to make it work. But I found a workaround.

Instead of wasting time finding how to do this, I made two different drone: One that the player can control, and one that only follow the player.
When the player switch to the drone, the following drone is made invisible, and the controlling drone is made visible and teleported to the position of the following drone. Easier to implement that way

Here is my glorious monster.

Imgur