Custom Movement Mode Creation

Hey everyone,

Iv’e been trying to figure out how to make my own custom movement modes in Blueprint, but their isn’t much documentation on how to do so, and I’m still not entirely sure what they actually are or how to use them. Im using UE4’s built in movement component right now, which is very nice, and has a few default modes like flying/falling/and swimming. What Id like to be able to do is make my own movement modes such as strafing, climbing, etc, and have separate movement logic for each one.

For example: Upon switching to a strafing movement mode, the character faces the camera direction and moves slowly. Or, upon switching to a climbing movement mode, the character faces a wall/moves up and down while rotation is locked…

Now I know I can modify the values of the default movement component (such as walk speed and orient rotation to movement) in-game by pressing buttons and so on, (which is what I’m doing now), But is it possible to store a bunch of movement logic in its own movement mode, and activate it on a button press or something? I know there is a function node for setting the characters movement mode, and it has various modes to select, but I’m just trying to figure out how to make and modify my own custom ones, If its even possible? Having multiple modes with different walk speeds, jump-heights, rotation-rates, and other character movement settings or custom movement logic would be ideal.

Id love to here what anyone has to say, and if anyone could explain what the custom modes are and how to make them, that would be great

Thanks in Advance!

Check out this tutorial, it should point you in the right direction. Unreal Engine 4 Wall Climbing 1/2 - YouTube In addition, you might check out https://docs.unrealengine.com/latest/INT/Gameplay/Framework/Controller/PlayerController/index.html and https://docs.unrealengine.com/latest/INT/Gameplay/Input/index.html

Sorry to just share links but the question(s) you asked have a huge scope.
Hope that helps!

Edit: And I almost forgot, https://docs.unrealengine.com/latest/INT/Resources/ContentExamples/Animation/index.html

Ive already seen everything that you’ve posted on the links…I do as much research as I can before asking a question. But I cant find any explanation of what a custom movement mode actually is? I know how to manage input, set up animations, and do a ton of other stuff, but ive got no clue as to what custom movement modes are.

Ah, I see, well then the only other thing I have for you is…

To use custom modes, you define an
enum that lists the custom modes you
want to use. You then use
SetMovementMode(MOVE_Custom,
YourCustomMode). In code, you override
PhysCustom(), look at what your
current mode is (CustomMovementMode
stored on the component), and then
execute your custom code. In
blueprints, you can tie in to
UpdateCustomMovement() instead, which
is very similar.

Ok…but how do I create and store these modes? I guess my real question should be, Do i define movement logic in a separate graph, and then set that to a certain movement mode? I cant find a definite answer or documentation on it anywhere, which leads me to believe that custom movement modes arent really what I think they are. I know how to modify the default movement mode in the character BP, and switch between pre-set types, like flying/swimming, But where and how do I go about setting up my own? This has halted my project for about a week now :(. Its very frustrating and unfortunate that no one seems to be able to explain what they actually are.

Ok thanks…I was hoping I could do it all in blueprint, but i guess not.

Thank you again for your time!

1 Like

I’m not sure how much more help I can be as I am just researching it, as you are (I’ve found that helping people research stuff here teaches me a ton about the egine). It would seem by definition, a custom movment mode is a derived class of the CharacterMovementComponent class (Engine/Classes/GameFramework/CharacterMovmentComponent). You can generate this in the editor by browsing to it in the engine C++ classes folder, right clicking it and selecting “Create class derived from”. That’s where you logic goes.

void
UMyMovementComponent::OnMovementModeChanged(EMovementMode
prevMovement, uint8
prevCustomMovement) {
Super::OnMovementModeChanged(prevMovement,PrevCustomMovement);

//Should probably set up an enum cast
to uint8 for checking against custom
mode (uint8)EMyCustomMovement::GLIDE
if(MovementMode==EMovementMode::Custom
&& CustomMovementMode == MyGlideUint8)
{ //Set my glider settings } }

https://forums.unrealengine.com/archive/index.php/t-49772.html

That’s about all I have to help, best of luck!

Blueprint

You can add the following events in your Character blueprint:

  • Use Set Movement Mode to change the movement mode based on some trigger in your game. Here, we do it in Event BeginPlay for debug.

  • Event OnMovementModeChanged is called when the Movement Mode changes, and allows you to add setup or teardown (exit) code for movement mode transitions. Here, we just use it for debug.

  • In Event UpdateCustomMovement, apply the update method for the current custom movement.

If you have several custom movements, check the Custom Movement Mode byte index (sometimes called sub-mode) to know which custom movement is currently active (e.g. 0 for Climbing, 1 for Driving, etc.). Note that Blueprint does not support switching over a byte, so we use a Switch on Int with a byte-to-int conversion.

For each sub-mode, apply the update method that corresponds to the current Custom Movement Mode.

Thanks to Sw hornet for making [this tutorial (link)][2]. I found that you could even get Custom Movement Mode directly from the CharacterMovement Component, so I skipped the step where the author stores the Custom Mode in OnMovementModeChanged.

C++

I suggest you to follow james0x0A and Tomura’s method on [the link provided by Purecyn][3] in the comments. To sum up:

  • Override ACharacter::OnMovementModeChanged(EMovementMode PrevMovementMode, uint8 PrevCustomMode) if you need setup/teardown code. It corresponds to the event OnMovementModeChanged for Blueprints. Note that james0x0A mentions UCharacterMovementComponent::OnMovementModeChanged which can also be overriden, but ultimately calls ACharacter::OnMovementModeChanged.
  • Override UCharacterMovementComponent::PhysCustom(float DeltaTime, int32 Iterations) to update when a custom movement is active. It corresponds to the event UpdateCustomMovement for Blueprints.

In both cases, I suggest you to call the base methods with Super()::___, since the base implementation call the Blueprint events. It will allow you to extend the character behaviors via Blueprints later.

4 Likes

That’s it! I’m pretty sure that’s what he was looking for. In any case that is exactly what I was looking for so thank you so much for the reply.
Blueprints FTW!
So just to double check, every custom movement logic I write as an extension of the character movement component (as shown in your blueprints example screenshot) will also automatically make use of the inherent replication, smoothing, correction and simulation functionality built into the character movement component. Is that correct?

I am also wondering this

Thanks, for some reason a wrong aswer is marked as solution, but your one is the actual one.