How to make my main pawn possessed by MyAIController?

How can i make my pawn become an AI as soon as it enters game? my main pawn is getting spawned by game mode!

i tried changing its default “AIController” to my created one “MyAIContorller”. it successfully started the behavior tree but blackboard value are not getting inserted using my main pawn blueprint.

i think its because my pawn is spawned by game mode. so its only a playable pawn not AI and apart from AIController kicking in blackboard values are all empty? why its happening? how to fix this?

Please don’t bump questions that are unanswered for less than 4 days. This will clutter the HUB and make it hard for other users to get their questions answered.

For you problem it would be nice to see your setup (pictures of nearly everything related). If you setup the AI Controller and the BT correctly, it should work. Are you sure you didn’t miss something?

Anyone with the answer ???

oh! sorry about that. i was just getting frustrated while trying my best to solve my problem on my own since i post the question… and i’m sure i didnt miss anything. i have setup everything correctly. other AIs are working fine as long as i dont use them as main character by spawning using “Game Mode”.

so overall problem is, “Game mode” spawning actor using it not working as AI.
probably because game mode only meant to work for playable character. if thats the case then how to change “player controller” to “MyAIController” afterward.

try it… use game mode to spawn Main character as AI. if works let me know!

Update: i have tried spawning my character using level blueprint as AI. result is good Behavior tree started working and Blackboard updating the values. exactly what i wanted. But thats not the correct way of doing it. its causing more problems now. for instance, using this way main character comes after event begin play and so all the blueprint that were using main character’s reference on “Event begin play” not kicking in. its messing things up even more.

Still looking for a proper solution. and trying continuously.

After not getting any answer from anyone. and not even getting any clue that, it is possible or not. i kept trying for two days until i came to a point where i assumed it’s not possible to make “game mode” spawned character work as AI. no matter where you set its AIController.

so i tried on workarounds rather than making this AI stuff work.

Workaround is pretty simple.

  • first i set my main character’s Controller to my “AIControllerBP” (which i wanted it to use in the first place) from the defaults tab.
  • then as game started i made my “Game mode” spawned character hidden and disabled its collision. (i did not destroy it cuz other blueprint still using it’s reference and i still wanted to give him its controls back to it)
  • then i spawned another main character with first character’s transformation. it obviously started working as AI because of the first step i did.

so, as i press some button i made my main character turn into AI from gamer’s perspective. and in advance pressing the button again destroys the 2nd main character (AI one) and unhides the main one. and shifts the main one to 2nd one’s position. and it worked! Finally :slight_smile:

You can’t set the Player Controller in the GameMode as an AI Controller. If you want a PlayerCharacter class to have a default AI Controller, you need to set it in the Defaults of the Character and change a setting to “When Spawned” (don’t know the name, but it is near the AI Controller Tab).

If you let the GameMode spawn the default pawn class, it will autoposses it with the set PlayerController. As far as i know, you can’t use an AI Controller there.

If you want to spawn a Character that is controlled by an AI Controller, you just need to create the BP Class of that character (that’s why you sperated AI and PlayerCharacter, even if they use the same BaseClass as a character) and set the default AI Controller to yours and change teh setting i mentioned above.

If you don’t want to have a PlayerCharacter spawned which is possesed by the normal PlayerController, just leave the Default Class as “NONE” in the GameMode.

The PlayerController is spawned 100%,because it is needed for most things than just controlling the pawn.

If you want to have another character that is controlled by this controller late, you can spawn it and use “Posses” (a function of the PlayerController) with it later.

Thanks! this info will help others clear the doubts that i had. :slight_smile: