SetupInputComponent in PlayerController
I know there's already a lot of threads explaining how to setup inputs in the playercontroller to move my pawn, but I tried to do so but I still can't manage to make it work. I've made a new PlayerController class, called CampaignPlayerController and I've also made a new public function, which is virtual void SetupInputComponent() override. Here's my .h file for my controller:
And here's my .cpp file:
Also, the functions MoveForward() and MoveRight() are defined in my Character-class. I'm simply trying to move my character using the player controller that I've made. How do I do this? The code above doesn't work and gives me red underlines my super-call, and gives me an error saying:
If anyone could help me it would be highly appreciated! Thanks in advance :)
asked Nov 06 '18 at 03:03 PM in C++ Programming
I think your issue may be that you're trying to call up a function belonging to a different class. Usually, you provide the
This explains the compile error you're getting: the compiler is telling you it cannot cast (convert) ACharacterBase to ACampaignPlayerController. It's expecting a function belonging to the ACampaignPlayerController class.
Here's another way of thinking about it. The way you have it set up right now, your PlayerController does not know which instance of
Try making a pair of new functions in your ACampaignPlayerController class, also called MoveForward() and MoveRight() if you want, and direct your BindAxis macros to those functions instead.
Then, from within the new movement functions, call up the existing MoveForward() and MoveRight() functions on your APlayerBase class using a pointer to specify which specific APlayerBase actor you want to respond to the input.
That should get things moving for you. (See what I did there?)
Best of luck!
answered Nov 06 '18 at 06:09 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here