Problems with switching between Player Controller and AI Controller

In my game, I have three characters that player can switch between.
My problem is that once character has been possessed by player controller, engine won’t let me then possess it again with an AIController.

63146-sdfsadfasdf.png

above blueprint doesn’t work and there doesn’t seem to be a reason for it not to. (This is in one of three character’s blueprints).

I setup this blueprint to a tick event and it tells me that this character starts off posessed by an AIController, then it gets posessed by a player controller, and then when unposessed it has no controller despite me scripting that it should.

edit: I was wrong, apologies for confusion!

Just tried it. Still getting same problem unfortunately.

Hi TheWTFage,

I’m not able to reproduce a problem with this setup, and there’s shouldn’t be a problem with running a possession on Event Unpossessed (that’s partly what it’s for). Are you sure character isn’t being possessed? If you run an Event On Possess inside appropriate AI controller with a print event, does it ever fire? Are you able to reproduce this in a new project? If so, would you mind uploading it somewhere and getting me a download link, so I can take a look? Thanks

Sorry for delay
Try this link:
https://.com/file/d/0BymRkfkNVXgna2ltdFRjRWcybFE/view?usp=sharing

It’s okay :slight_smile: Thanks for trying!

Hi TheWTFage,

It looks like primary problem in project you provided is that AI Controller variables in your Player Controller and each Character BP is not being set anywhere. So each place you’re running Possess node with one of these variables, you’re getting an Accessed None error because variables are empty. After Playing, you can see these in Message Log.

I’ve tried setting these variables for AI Controllers in several ways now and each time I try to play game, engine crashes without providing me with a minidump. Could you try demonstrating what you mean in project file provided?

https://.com/file/d/0BymRkfkNVXgnOVFMWXh2ZEhiOUE/view?usp=sharing

Ah, yes, that crash is a bug in 4.9 (UE-22326) that’s been fixed in 4.10. It causes a crash when you attempt to possess a character with an AI Controller on Event UnPossessed. That method is smarter, and it will work in future (and past) versions other than 4.9.

To get around that in 4.9, you should possess current pawn with AI Controller after Player Controller possesses something else. This is how I did it in your project. First, disconnect what you have connected to Event Unpossessed in each character.

Next, set a temporary reference to Controlled Pawn in your Player Controller:

Then, set this up further down chain where you do your possession:

Hope it helps!