I Need to Make the Up Arrow Key On the Keyboard Send My Pawn to Different Locations in My Scene

I have been trying to figure out the Blueprints to the following function. Any help would be greatly appreciated. I need to make the up arrow key on the keyboard send my pawn to different locations in my scene.

In other words, how can I set up my Blueprints so that the up arrow, when pressed, sends my pawn to a different location in my scene, then when the up arrow is pressed again, it will send my pawn to yet another location within my scene; and this must be done for 6 different locations?

I got the Blueprints set up so that I can send my pawn to a different location in the scene, however, I need to send my pawn to several other locations within my scene by using the same up arrow key again.

I also need to use the down arrow key multiple times to go back to previous locations the pawn had just come from.

I would greatly appreciate any help, thank you so much!

try this:

Scott, thank you so much for getting back to me so quickly! I really appreciate it! I am very new to Unreal Engine Blueprints, thus all the variables i.e. <, >, +, as well as GET, SET, and LENGTH are completely unfamiliar to me.

By any chance, could you explain the steps involved in building this node tree?

Thanks again, I really appreciate the help! I was stuck for over a week on trying to find something out there on this kind of functionality.

start by right clicking in the event graph background, and type AddCustomEvent. then name that custom event LoopingCustomEvent, or whatever you want to call it. then add another node, this time, typing in SetTimerByEvent. drag off the blue output pin return value, and select promoteToVariable, and name it MenuCursorTimer.

in your project settings you will have to make inputaction events and inputAxisEvents.

you should make Input actions for Up_Btn, Down_btn, and make an input axis event called MoveUp. these should be set up with the gamepad left joystick and the W and S keys.

then you just create a vector variable, turn it into an array by clicking on the icon that looks like 9 squares next to the variable type dropdown menu. then create an integer variable, which keeps track of the current index into the array, allowing you to pick 1 element out of that list of locations, using the Array Get node.

to find nodes like Get and Length, you just drag off of an array variable. for nodes like Set, you select those when you drag a variable from the variables list into the event graph.

as for < > + etc… those are just math nodes (less than, greater than, and addition), when searching for < , it should say “float < float” or “integer < integer”, which allows you to compare either decimal numbers (floats) or counting whole numbers (integers).

This is what I have so far.

Also the following image includes the highlighted nodes from your Blueprint that are completely unfamiliar to me.

the red one is a custom event, you use AddCustomEvent to create that. its like a function that can be called, but it doesn’t return any variables. GetMoveUp is an input Axis Event, and to find that, first you have to set up your inputs in your project settings. the other nodes are all variables you add to the blueprint, integers, array of vectors, and timer handles.

read through this introduction to Blueprint Variables, it will teach you how to create variables, set them, and get them.

My apologies Scott, I sent you these two the images before I noticed your reply above. I really appreciate all your help, thank you so much!

I went ahead and built out the blueprints, but when I compiled and played the game, my pawn didn’t move anywhere.

Do you know where I can plug in the X, Y, and Z values for where my pawn should teleport in the scene when hitting the up and down arrows? I have specific X, Y, and Z values for each specific location.

Also, I don’t know if this is necessary but, where would I plug in my pawn node?

These are the inputs I created and I was wondering if they were correct?

Thanks again Scott! I really appreciate it!

you should put this code inside your custom character blueprint, not the level blueprint.

characters should be responsible for moving themselves, and pawns/characters are often responsible for controller input logic, so it would be better to put this code inside the character. usually, most code belongs in actors placed in the level, rather than putting code in the level blueprint, because you usually want to be able to reuse code in other levels.

Greetings Scott, it was brought to my attention that the Blueprints you are suggesting might be too intricate for what needs to be accomplished.

Maybe if I reword the desired result a simpler blueprint might come to mind.

On this image, I have several SetActorLocations. Within those SetActorLocations, I have a constant Y and Z value, while the X is
changing.

I need to hit the up arrow key to send my pawn, to the first SetActorLocation.

Then when I press the up arrow key again, I need the pawn to be sent to the second SetActorLocation.

Same again for the rest of the SetActorLocations.

What I have set up in this image works, but only once.

I need to simply repeat the function, of the up arrow, sending my pawn to the second, third, fourth, etc… SetActorLocations, by pressing the Up arrow key.

I hope I was able to provide clear information for you. If you could guide me towards this end result, I would deeply appreciate that.

My apologies for the confusion. Thank you so much! All the Best!

if you want it to be simpler, you can remove the timer, but that would remove the feature where the player can hold the button to cycle through the locations. the rest of the code is necessary, it just increments an integer index, bounds checks that index so its within the size of the array, and sets the location of the pawn. it honestly cant get any simpler than that without breaking the functionality or safety of the operation.

Thank you for the reply Scott. I understand, I am just a little confused as I don’t see where the X,Y,Z value inputs are here. Basically, where is the pawn teleporting to in my scene with the up key press, using the blueprints you’ve created? I have very specific locations in X,Y,Z.

I also don’t understand where to plug in my Pawn node. I believe this is where you suggested to put the blueprints in the pawn’s blueprints and not the Level Blueprints. I tried this, and it still did not work.

I will build these Blueprints again from scratch within the pawn’s Blueprints and not the Level Blueprints. I will type up every step I took, in order to try and troubleshoot this problem.

I believe that your Blueprints are accurate, and would greatly appreciate its functionality.

Thank you again Scott, I really appreciate, and respect your help and persistence.

you can set up the locations in the default properties of the array of vectors.

Do you know where I may locate the default properties of the array vectors?

HERE ARE THE STEPS I TOOK. I HOPE THIS IS CLEAR AND CONCISE. IF THERE ARE STEPS THAT I HAVE MISSED OR MADE A MISTAKE ON, I WOULD MORE THAN APPRECIATE BEING FILLED IN ON. THANK YOU SO MUCH! More Below

  1. Create Pawn Class Blueprint
  2. Open Class Blueprint
  3. Enter the Viewport of the Pawn’s Blueprint.
  4. Add Component, and search for “Capsule Collision” and select it.
  5. Add Component and search for “Scene” and select it.
  6. Add Component and search for “Camera” and select it.
  7. From the Components panel, drag Camera over Scene and let go to parent.
  8. Adjust camera’s height to where a head would be.
  9. Enter the Event Graph of Pawn’s Blueprint.
  10. Go to Edit> Project Settings
  11. Under “Engine” in the Project Settings window, select “Input”.
  12. Add two “Action Mappings”
  13. Label one “Up_Arrow” and the other “Down_Arrow”
  14. Set the up arrow key to “Up_Arrow” and down arrow key to “Down_Arrow”.
  15. Then add one “Axis Mappings”.
  16. Rename to “MoveUp”
  17. Set keys to W and S.
  18. For S, set scale to -1.0.
  19. Go back to Event Graph of Pawn.
  20. Create the 2 nodes of the up and down arrow Input Actions I just set up.
  21. Bring in a Sequence node.
  22. Connect the “Pressed” outputs from Up and Down arrow Input Actions to the flow input of Sequence node.
  23. Create a “Clear and Invalidate Timer by Handle” node.
  24. Connect the “Released” outputs from Up and Down arrow Input Actions to the flow input of “Clear and Invalidate Timer by Handle” node.
  25. Drag out blue wire from “Handle” of “Clear and Invalidate Timer by Handle” node and promote to variable.
  26. Rename the newly create “Timer Handle” to “Menu Cursor Timer”.
  27. Create a “Set Timer by Event” node and change its time to “.3” while check on “Looping”.
  28. Connect “Then 0” from Sequence node to flow input of “Set Timer by Event” node.
  29. Drag red wire out of the “Event” input of “Set Timer by Event” node and search for “AddCustomEvent”.
  30. Rename “Add Custom Event” node to “LoopingCustomEvent”.
  1. Create another Sequence node and click “Add pin” on the node itself.
  2. Connect flow output of LoopingCustomEvent node to input of second sequence node.
  3. Plug in “Then 1” from first Sequence node to flow input of second Sequence node.
  4. Bring in “Menu Cursor Timer” variable created earlier and select “Set”.
  5. Connect the flow output of the “Set Timer by Event” node to the flow input of the blue “SET” node.
  6. Connect the blue “Return Value” output of the “Set Timer by Event” node, blue “Menu Cursor Timer” input of the blue “SET” node.
  7. Create two Branch nodes. 1st Branch node is above 2nd Branch node.
  8. Create a “Float < Float” node.
  9. Create a “Float > Float” node.
  10. Connect the “Then 0” from the second Sequence node to the flow input of the 1st Branch node.
  11. Connect the “False” output of the 1st Branch node to the flow input of the 2nd Branch node.
  12. Connect the red output of the “Float > Float” node to the red “Condition” of the 1st Branch node.
  13. Connect the red output of the “Float < Float” node to the red “Condition” of the 2nd Branch node.
  14. Create a “Get MoveUp” node.
  15. Connect the green “Return Value” output of the “Get MoveUp” node to both of the top green inputs of the “Float > Float” node and “Float < Float” node.
  16. Change the bottom green input value of the “Float > Float” node “0.5”.
  17. Change the bottom green input value of the “Float < Float” node “-0.5”.
  18. Create a Vector Array and name it “Array Destination”.
  19. Create an Integer Variable and name it “Current Destination”.
  20. Create a 3rd and 4th Branch node. 3rd Branch node is above 4th Branch node.
  21. Connect the “Then 1” of the second Sequence node to the flow input of the 3rd Branch node.
  22. Connect the “False” of the 3rd Branch node to the flow input of the 4th Branch node.
  1. Create a “SetActorLocation” and check on “Teleport” within the node itself.
  2. Connect the “Then 2” of the second Sequence node to the flow input of the “SetActorLocation” node.
  3. Create “Array Get” node.
  4. Bring in the “Array Destinations” vector array, and select “Get”.
  5. Connect Array Destinations node into the squared input of the Array Get node.
  6. Bring in a Current Destinations Variable node and plug it into the green input of the Array Get node.
  7. Connect the yellow output of the Array Get node to the yellow input of the SetActorLocation node.
  8. Create an “Integer > Integer” node.
  9. Create an “Integer < Integer” node.
  10. Connect the red output of the “Integer < Integer” node to the red Condition input of the 3rd Branch node.
  11. Connect the red output of the “Integer > Integer” node to the red Condition input of the 4th Branch node.
  12. Bring in a Current Destination Variable and select Get.
  13. Connect the Current Destination node into the top green input of the “Integer < Integer” node.
  14. Bring in another Current Destination Variable and select Get.
  15. Connect the Current Destination node into the top green input of the “Integer > Integer” node.
  16. Create an “Array Length” node.
  17. Connect the green output of the Array Length node into the bottom green input of the “Integer > Integer” node.
  18. Bring in the “Array Destinations” vector array, and select “Get”.
  19. Connect the Array Destinations node into the squared input of the Array Length node.
  20. Create two “Integer + Integer” nodes.
  21. On the bottom value of one of the Integer + Integer nodes, set the value to “-1”.
  22. Bring in two “Current Destinations” and select “Get” for both of them.
  23. Plug one of the Current Destinations into the top green input of the Integer + Integer node, and do the same for the other.
  1. Plug one of the Current Destinations into the top green input of the Integer + Integer node, and do the same for the other.
  2. Create an Array Length node.
  3. Bring in the “Array Destinations” vector array, and select “Get”.
  4. Connect the Array Destinations node to the squared input of the Array Length.
  5. Bring in four Current Destination nodes and select “Set” for all four.
  6. Connect the “True” of the 1st Branch into flow input of the first “Set” Current Destinations node.
  7. Connect the “True” of the 2nd Branch into flow input of the second “Set” Current Destinations node.
  8. Connect the “True” of the 3rd Branch into flow input of the third “Set” Current Destinations node.
  9. Connect the “True” of the 4th Branch into flow input of the fourth “Set” Current Destinations node.
  10. Connect the green output of the Integer + Integer node which has a value of “1”, to the input of the first green SET Current Destinations node.
  11. Connect the green output of the Integer + Integer node which has a value of “-1”, to the input of the second green SET Current Destinations node.
  12. Connect the green output of the Array Length node to the input of the third green SET Current Destinations node.
  13. Go to the game’s viewport and drag and drop pawn into scene.
  14. In the Details panel, under Pawn, change “Auto Possess Player” to “Player 0”.
  15. Create a new Game Mode class blueprint and double click the icon in Content Browser.
  16. In the Details panel of Game Mode, under Classes, change “Default Pawn Class” to “My_Pawn” (which is the name I made for my pawn).
  17. Hit Compile and Save on everything.

MY APOLOGIES ABOUT THE NUMBERING. IT CHANGED WHEN I PASTED IT INTO HERE, HOWEVER THE NUMBERING IS STILL ACCURATE. AFTER MY SECOND ITERATION OF THIS BLUEPRINT, IT STILL DIDN’T SEEM TO WORK.

BELOW IS THE NEW PAWN BLUEPRINT: