Just getting started with UE4. I’ve extended the UCharacterMovementComponent, and currently I have overrode the TickComponent. Within the TickComponent I check to see if I should enter a different MovementMode. If that is true, I set the movement mode to MOVE_Custom. My question is: should I then check, inside of the TickComponent if the current movement mode is one of my custom ones to perform that movement logic, or is there a method I can override where that is performed in the MovementComponent? I’ve walked through the component parent classes and cannot find anything.
If my only option is to do it all within my TickComponent that’s fine, but If I can better fit my code into any order that the game is following I’d like to do that. I’d rather start off with good practices than do things in a hacky and less preferred way.
As a side note, if there is a better place to check what my current mode should be, please let me know too!
I do something similar, but I believe the correct flow is to do your actual movement in “PhysCustom”, not in the tick. PhysCustom will only tick when the movement mode is MOVE_Custom.
As you have probably already noticed, when you set the MOVE_Custom mode, you can set an additional uint8 value (CustomMovementMode) and then you can switch on that in PhysCustom and forward it to “PhysWallRun” or whatever custom movement you have to make things cleaner.
You can look at the other Phys methods (such as PhysFalling) to get an idea of how best to implement the custom mode.
Awesome, that’s exactly what I was looking for. Thanks so much. Is there a similar method that I should be harnessing for determining which movement mode/state that the character should be in? Like I mentioned I am doing that in the tick, and that feels more correct, but figure I’d double check to see if anything else exists.
I determine the mode in the Tick, I haven’t found a better way of doing that.
For instance, I raycast out from the character if they are falling, to determine if they should mount up into a wall run etc, and I do that in the TickComponent.