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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Is it possible to use both PlayerController and AIController with the same Pawn?

In my top-down game (made from top-down C++ template) with pawn's movement controlled by mouse clicking, I want to use MoveToLocation method of AAIController but I can't since I use a controller derived from APlayerController which doesn't have such functionality. Is there a way for me to use this moving functionality with my player pawn or achieve same result with something else?

I tried using AIController for my pawn and using Player Controller in spectator mode but then it does not get attached to the camera.

Product Version: UE 4.21
more ▼

asked Feb 14 '19 at 12:29 AM in Using UE4

avatar image

3 1 2

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

1 answer: sort voted first

i dont know about C++ but in blueprint its not all that hard to do something similar. below is a little test script i made which if im getting you right is what your trying to accomplish. this is done in the player controller and the idea is to move a character via mouse clicks without possessing it. basically i get the hit result under cursor and if its a character i set the variable character to control then i set the view target which makes player controller use the characters camera. if i click with the mouse and its not a character then it moves the currently selected character to where i clicked.

obviously this is incomplete lacking is valid checks and such but its a proof of concept. im sure you could use something similar in C++.

alt text

capture.png (191.2 kB)
more ▼

answered Feb 14 '19 at 12:53 AM

avatar image

10.1k 33 10 23

avatar image Satus76 Feb 14 '19 at 01:28 AM

Huh, I didn't know about SetViewTarget method. I will do more testing but seems like this is it, thank you very much.

avatar image ThompsonN13 Feb 14 '19 at 02:51 AM

yup it allows you to switch cameras and if you add in a blend time it will move the view by blending which is nice. course you could probably just have a camera pawn that you posses and move that to center on whichever actor you select.

(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