Storing Pawn once for all in Player Controller
I didn't find the answer to that, so here is my question : Can I cast and store the pawn in his controller once for all ? I'm using my Controller to handle player's inputs, and the Pawn should NOT change during the game. At first, I was handling everything directly in the Pawn itself and it was working fine, but for training purposes, I'm willing to switch everything to the Controller.
So basically what I'm trying to do is to call the moving function that is inside the Pawn from the Controller. The following code works, but force me into casting the pawn for EVERY functions. Plus, this is going to be called everytimes the player try to move or rotate the camera. I tried to make a ACommander * variable in the .h of the Controller and set it like below in the constructor so it's set once for all, but it doens't seem to work.
Any idea how I could cast+store the pawn once ? So I could write something like :
The Character Pawn contains all of the movement functions. For most functions such at movement you will have to cast to the Character Pawn repeatedly unless you store a reference to it inside of an variable.
Personally I would not recommend that you store your movement control data in the Player Controller as it is not designed for that.
It can be done with a bit of work but it is unnecessary.
answered Dec 21 '16 at 04:51 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here