ACharacter and APlayerController Tick Interfering
I've been messing around with my custom ACharacter & APlayerController code. I'm confused about the differences of these base classes, I see the ACharacter is associated with an actual pawn object, and I suppose APlayerController can be associated with the movement functionality. However, ACharacter can also be associated with the movement functionality if we wanted that there instead. Is it setup like this just for flexibility, or are there situations where I should make sure I'm keeping these separate correctly?
My main problem is, within my ACharacter I have a Tick function that is executing some movement behavior. However, I started messing around with the APlayerController and I added it's own TickActor functionality there and now it seems that TickActor functionality is overriding my ACharacter functionality. Should I be making sure to just keep this sort of functionality contained to one of these classes or the other?
It seems like functionality is being disabled in my ACharacter. I just noticed that my AMyCharacter::SetupPlayerInputComponent isn't being called anymore either.
Thank you for any insight.
APlayerController is associated with players and it is how you get inputs to your character from your keypresses. It remains when your character dies - it only resets when you change levels. ACharacter is, as you said, the physical representation of the character. Movement functionality is best to keep in UCharacterMovementComponent which is loaded as a character component. That will allow you to have custom movement types for different types of pawns and allows you to invoke either the same movement for all your pawns or then have a separate movement for for example vehicles. Having movement logic in ACharacter is also possible. Depending on the type of game you are running, APlayerController is usually the best place to keep the aiming logic and to control what is on your screen, ie. the viewport, because APlayerController is where you inputs are received.
There are some differences in how Characters, MovementComponents and PlayerControllers are replicated, so if you are making a multiplayer game, you should really look into that before going forward.
SetupPlayerInputComponent is called from PlayerController whenever a pawn/character is possessed, if my memory serves me correctly. You might have changed something in that regard. Or maybe you forgot to override it in AMyCharacter? Difficult to say without access to code.
answered Apr 26 '16 at 10:31 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here