How to change character movement from one direction to another?

Hi

How would i be able to make main player constantly move in one direction like moving right without player control and player must move up and down to avoid obstacles, and then when player enters a trigger volume constant direction must change from moving right to moving up or down and then player must move left to right to avoid oncoming obstacles?

thx

Hey CmsToxic,

If you use a pawn with CharacterMovement component, you can set up continuous movement in a direction with an Event Tick node and Add Movement Input node. Make a vector variable for World Direction input and give it a base value of 1 or -1 along axis you want your character to be moved.

To set up a change in direction using a volume, I would create an Actor Blueprint. Make an empty SceneComponent root, and then make a Box Component for your trigger volume. Then in EventGraph, cast to your character and set that Direction variable to new direction you want your character to be moving.

Then you just need to set your controls to only respond along axis you want depending on current Direction. This is how I have mine set up using Blueprint Side Scroller template:

Direction is a vector variable with a default value of 0.0, -1.0, 0.0. I added an Input for MoveUp in Project Settings that lets my character move up and down. You’ll need to set Gravity Scale for character to 0.0 for this to work (Under Defaults for Character Blueprint, search for Gravity). I’m then doing a check to see which Direction character is being pushed in; if left or right, I enable MoveUp input, and if up or down I enable MoveRight input.

Here we’re just updating Direction that character is being pushed by Add Movement Input node on Event Tick. Make New Direction vector variable editable. When you place this Blueprint in your level, you’ll be able to adjust size of Box Volume and give it a New Direction value in editor.

Hope that helps! Let me know if you have any questions.

Hi

Thx for answer, i just want to know how would i be able to setup continuous direction movement if my character’s movement blueprint looks like this…

Because if i try and save it when inputting your blueprints for directional movement, it keeps giving me this Message…

11103-54yrger.png

What I suggested above only works if you’re using CharacterMovement component, which your pawn does not. It looks like you’re following 6DOF tutorials. In this case, you’d want to set up something similar but set New Vel of a Set Physics Linear Velocity node to your Direction variable.

11111-directionswitchervelocitytick.jpg