Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How to normalize movement

Hello Community, I am programming a simple top down shooter in C++ using the Unreal Engine. Everyting is working as expected and perfectly, except for one thing: I am using a Player Controller to move the Pawn throw the World. The Problem is that when i press A (Walk Left) and W (walk forward) at the same time my charackter is way faster than just pressing a single Button.

// Input for Forward and Backward void APlayerCharackterController::MoveForwardAndBackward(float Value) { if (Value != 0.0f) { APawn* const PlayerCharackterPawn = GetPawn(); PlayerCharackterPawn->AddMovementInput(GetActorForwardVector(), Value); } }

// Input for Right and Left void APlayerCharackterController::MoveRightAndLeft(float Value) { if (Value != 0.0f) { // add movement in that direction APawn* const PlayerCharackterPawn = GetPawn(); PlayerCharackterPawn->AddMovementInput(GetActorRightVector(), Value); } }

So, I am pretty sure why this problem is there, but I have no Idea how I can solve this problem. I thought about normalizing a Vector, but, as I alredy said, i have no Solution to this problem. I just want to move the Pawn in the same speed when i press one or two buttons.

Thank you in advance for yout help

ps: sorry for my bad english ;)

Product Version: UE 4.15
more ▼

asked Apr 29 '17 at 01:04 PM in C++ Programming

avatar image

1 2 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first


Dont move your charater on Key event. In key events juste set a boolean that say if player is pressing button.

Then in the Tick function of your charater, you test all boolean for all directions. You decide the direction to take and move your charater in that direction.

more ▼

answered Apr 29 '17 at 01:58 PM

avatar image

293 11 8 20

avatar image 42EspoiR Apr 29 '17 at 02:00 PM

Don't forget to multiple le Velocity value with DeltaTime to not be Frame dependends

avatar image FROPB Apr 29 '17 at 03:08 PM

Thank you very much! I will try it out as soon as possible ;)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question