So another random blog post. There are almost yearly gaps between these things, oh well.
I'm currently building an RTS sample with UE4 C++. First class was a FieldView class that acts as a player top down camera. Second class is Unit class that will receive command from player character and do their thing.
Conceptually, a Unit won't take input directly from character and really at the time I thought inheriting class Character would be an overkill. The issue is that a Unit needs a path finding capability -it's an RTS after all- and for that we need an implementation of NavMovementComponent.
PawnMovementComponent does inherit NavMovementComponent, but the default implementation are just placeholders. Once I realized this, overriding the needed methods is easy and you can move your pawn with path finding from a controller via SimpleMoveToLocation(this, DestLocation).
There are three parts to doing this. If you already have an implementation of a controller class and a pawn + PawnMovementComponent class than you can skip the first two steps.
Part 1:
Set up a Controller class.
Implement a Pawn class with a custom PawnMovementComponent. Follow direction from:
https://docs.unrealengine.com/latest/INT/Programming/Tutorials/Components/index.html
And add NavMovementComponent implementations:
That's it!
When I first attempted implementing PawnMovementComponent, it was a huge hassle and less functionality than CharacterMovementComponent. But once I got the code running, the actual implementation is far less and if you are planning to build a large library of customized MovementComponent (usually for RTS game with variety of units) it's somewhat useful.
PS:
Sorry for the poor quality of the sample above! It really should be submitted to git so that I can continuously improve it, but can't be bothered with git LFS, so I guess I'll just upload whatever code snippet I think is useful here.