x

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"

Set different playercontroller in game mode

I made a new c++ project and started the c++ programming tutorial. Now I want to increment an integer variable whenever I click on my actor.

I googled a bit and apparently I have to enable mouse input in the player controller. I made a new one since I didn't have it already. Now I need to set the player controller in the game mode. I can't edit the player controller with project settings - maps & modes (everything is greyed out). I'm guessing that is because it is a c++ project. So I have to change the playercontroller in my gamemode.cpp file? There's no playercontroller variable or a setplayercontroller function as far as i know, so how do I do this?

Or would it be better to make a new blueprint gamemode and set a blueprint playercontroller in the project settings?

thanks.

Product Version: Not Selected
Tags:
more ▼

asked Mar 04 '15 at 10:37 AM in C++ Programming

avatar image

Ixaeon
50 16 14 18

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

1 answer: sort voted first

Wiki For You

I have a wiki on exactly this subject :)

This is a C++ solution

Linking Custom Player Controller to Game Mode https://wiki.unrealengine.com/Game_Mode,_Linking_to_Player_Controller_Blueprint

Rama

more ▼

answered Mar 04 '15 at 11:16 AM

avatar image

Rama
10.6k 446 346 1088

avatar image Ixaeon Mar 04 '15 at 12:54 PM

Hi Rama,

Thanks for the article! I have a few questions though. My player controller blueprint is called MyPlayerController so I changed the type from AYourPlayerController to AMyPlayerController, but it says it's undefined?

Where do I put the code? My cpp is just an empty file apart from a few includes, do I need to override a function?

avatar image Dune Mar 04 '15 at 03:30 PM

It sounds like you need to include your MyPlayerController class' header file. Search for "class AMyPlayerController" and include the file that this class is declared in. If you search for "class AMyPlayerController" and it isn't found, then you haven't created that class anywhere.

avatar image Flymemory Aug 07 '16 at 06:30 PM

I have the same issue. It seems the FPostConstructInitializeProperties not defined. I noticed your YourPlayerController.h not declare AYourPlayerController(), do i miss something?

avatar image rfolea Dec 11 '16 at 03:48 PM

Hi Rama,

  1. Once I have set the player controller class per the Wiki, I still need to spawn the new player controller - right?

  2. This Wiki uses FObjectFinder. Could we avoid that and use a UPROPERTY( ... and TSubClassOf and assign the object in the Editor? If so, how would that work (I tried without success ..)

(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