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 to Posses Pawn with custom AI/Player Controllers

Ive been looking for a solution to this but there is no documentation or answer anywhere on how to do proper possession.

I have my custom character BP class and custom AI/Player controllers that both can possess the character using automatic possession.

alt text

I need these options OFF i dont want the framework to decide when and what to spawn, i need full controll over controller spawning and possession.

https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/PossessPawns/Blueprints/index.html This isnt helpful, it uses references to existing level pawns, it doesnt use AI controllers, and its not spawning any controllers they get spawned automatically.

The only functions i could find are:

-Spawn Default Controller(have no idea what that means, i dont need a default controller i need custom AI/Player controllers, how do i spawn controllers from custom controller class?) Also this func doesnt give me the spawned controller reference result.

-Possess and Unposses have no documentation or i cant find it.

What i need is a way to spawn a custom AI/Player Controller (or multiple ones) and then possess spawned Pawn's with them be it in the level blueprint or a custom BP that manages the spawning of things in the level which can persist between levels, i dont want my pawn/controllers references in my level blueprint.

Do i have to implement functionality from scratch in C++ if i want control over my pawns and controllers?

Product Version: UE 4.17
more ▼

asked Oct 23 '17 at 12:13 PM in Blueprint Scripting

avatar image

13 1 3 6

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

1 answer: sort voted first

The easiest setup would be something like this in your AI blueprint:

alt text

You will have an AIController variable which holds the controller class. You spawn the controller and posses self. BeginPlay is called each time you spawn a new actor, so when you spawn the AI this will be automatically called, the controller will be spawned and it will posses the current actor.

screenshot-22.png (103.5 kB)
more ▼

answered Oct 23 '17 at 01:06 PM

avatar image

154 2 3 7

avatar image KingVario Oct 23 '17 at 03:06 PM

Ok i solved the spawning part, my bad i didnt check that Controller class inherits from Actor so i can spawn it like any other actor. Ok so when i spawn a Character i also tell it to spawn an AI Controller from a Class variable which is set to my custom AI_Controller, but calling Possess with self on this AI_Controller does not work.

For some reason when i try to print the controller name on spawned character it returns empty string instead of my AI controller. In the World Outliner there is an AIController spawned and the character was possessed by it since the character falls to the ground after spawn, if i dont possess him it stays in air, but the AI controller code isnt working either and when i try to print it its empty.

I am very confused right now, its getting possessed but its not possessed by any controller?

And why is the engine spawning my default custom PlayerController that i set inside game mode? my custom player controller has most of the input code in it for the player and if i choose to not spawn a default character bp(set to none) the engine spawns a default pawn and attaches the custom player controller to it and i get lots of errors.

How do i stop the engine and the game modes for spawning stuff automatically, i need full controll over it.

(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