Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How can I change the controller that my character uses during gameplay?

I have four instances of the same character blueprint in my level - each of which can be possessed. At level start one is possessed by the player controller and the other three act upon an aicontroller blueprint.

When one of the other instances of the character is possessed by the player controller, the previously possessed character does not currently act upon the aicontroller.

Is there a way to make a character swap from using the character controller to using the ai controller when it ceases being possessed?

Thanks in advance.

Product Version: Not Selected
more ▼

asked Oct 07 '14 at 10:02 PM in Blueprint Scripting

avatar image

82 26 24 29

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

All you need to do is implement ReceiveUnpossessed event in your BP Pawn class and when OldController passed with the call is a PlayerController then you need to instantiate new AIController and tell it to posses the pawn in question.

Let me know if you have any more questions.



more ▼

answered Oct 08 '14 at 08:50 PM

avatar image

MieszkoZ STAFF
7.3k 223 57 412

avatar image ThatJoeThom Oct 16 '14 at 10:43 PM

Hi Mieszko,

I have made some progress but could use a little more help if you don't mind. This is what I currently have set up in my character blueprint:

alt text

With this setup the pawns do not use the ai controller on begin play, they just remain static when they should be moving around.

Also, when a character is unpossessd, all of the pawns (except for the one that is now possessed by the player controller) should begin to use the ai controller, but currently only the one that was previously possessed by the player does this.

Is there a way that I can have all pawns except the one that is possessed by the player use the AI controller on begin play and also have all pawns except for the one that is newly possessed by the player, use it when the previous pawn is unpossessed by the player?

Many thanks, Joe

avatar image MieszkoZ STAFF Oct 19 '14 at 05:49 PM

It sounds like you're using SpawnActor to spawn your AI pawns while you should be using SpawnAIFromClass. If you are using SpawnAIFromClass then it sounds like there's a bug and it would be awesome if you shared your project with us.

Alternatively you can just spawn AIController in pawn's ReceiveBeginPlay and then call Posses on the controller.



(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question