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"

How to make a character move direction by an exact distance?

Hi I'm planning on making my project a top down game.

Is there a way to press 'W' key to make the character move a specific distance like 100 grid squares and stop?

Product Version: UE 4.9
more ▼

asked Apr 27 '16 at 06:23 PM in Blueprint Scripting

avatar image

43 26 31 38

avatar image Est_engine Apr 29 '16 at 10:31 AM

hi man , area you using some handmade blueprint or are you using the navmesh?

avatar image MattStH Apr 29 '16 at 10:34 AM

I haven't started I tried a couple thing but got nowhere with it. So back to step one really.

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

3 answers: sort voted first

hey! you did not specify which way you wanted your character to move, i am just assuming that you want him to go the way he faces. alt text

get forward vector always returns a vector with length of 1, so we are getting a vector with length of 1, facing the way our character is facing, multiplying it with say like "100", and adding it to our current location

01.png (97.7 kB)
more ▼

answered Aug 28 '16 at 08:49 PM

avatar image

397 5 5 13

avatar image ChrisSweetwood May 24 '18 at 11:16 PM

This solution worked perfectly for me. Thanks so much -Chris

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

You can use the movement component, or the navmesh and a couple of other things. Using some of these you just need to give him the location where you want to go. Lets keep it simple, but keep in mind that the way you choose to manage the movements is really important.

For now, lets use my favorite way. Simple actor with custom blueprint. If you have an actor and want to move it of some meters in a direction , you have to.

Give the actor a variable like a vector , to use as target. you have to put on a system to make all gradually so.... Make the actor turn to look at the right direction. you can calculate the rotation using "find look at rotation" node. Now use the node "LerpR " to transform , your rotation , in the desired rotation..... Now you can use ""Set actor rotation"" , doing this you will have an actor turn to the location .

once your actor in looking the right direction you can start moving. Its quite simple if you have the location. just set the world location of your actor , this way. Get your actor location:add a vector (Vector forward). this will move the actor on forward of 1unit. You can multiply the vector by a Speed value, like 5 , to make it move at 5 unit per time. The very last thing is create an ""IF"" , before move, you want to check how much close to the location you are. So take the location of the actor - subtract the desired location and use the node , lenght vector. if this value is lower than 0.1 , you are there. To fix perfectly you can teleport in the exact location , and we are done. hope its clear

more ▼

answered Apr 30 '16 at 11:35 AM

avatar image

1.2k 58 12 62

avatar image MattStH May 01 '16 at 10:56 PM

Thank you for your help, but I still cant get it to work. If you have done it before can you provide any pictures of this?

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

Few days back I was also trying to achieve the same thing. You can go through this post: How to move my charater for specific distance just single key press? https://forums.unrealengine.com/showthread.php?117815-How-to-move-my-charater-for-specific-distance-just-single-key-press

Hope it helps.

more ▼

answered Aug 28 '16 at 07:25 PM

avatar image

31 3 2 3

(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