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!
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
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
- Create Pawn Class Blueprint
- Open Class Blueprint
- Enter the Viewport of the Pawn’s Blueprint.
- Add Component, and search for “Capsule Collision” and select it.
- Add Component and search for “Scene” and select it.
- Add Component and search for “Camera” and select it.
- From the Components panel, drag Camera over Scene and let go to parent.
- Adjust camera’s height to where a head would be.
- Enter the Event Graph of Pawn’s Blueprint.
- Go to Edit> Project Settings
- Under “Engine” in the Project Settings window, select “Input”.
- Add two “Action Mappings”
- Label one “Up_Arrow” and the other “Down_Arrow”
- Set the up arrow key to “Up_Arrow” and down arrow key to “Down_Arrow”.
- Then add one “Axis Mappings”.
- Rename to “MoveUp”
- Set keys to W and S.
- For S, set scale to -1.0.
- Go back to Event Graph of Pawn.
- Create the 2 nodes of the up and down arrow Input Actions I just set up.
- Bring in a Sequence node.
- Connect the “Pressed” outputs from Up and Down arrow Input Actions to the flow input of Sequence node.
- Create a “Clear and Invalidate Timer by Handle” node.
- Connect the “Released” outputs from Up and Down arrow Input Actions to the flow input of “Clear and Invalidate Timer by Handle” node.
- Drag out blue wire from “Handle” of “Clear and Invalidate Timer by Handle” node and promote to variable.
- Rename the newly create “Timer Handle” to “Menu Cursor Timer”.
- Create a “Set Timer by Event” node and change its time to “.3” while check on “Looping”.
- Connect “Then 0” from Sequence node to flow input of “Set Timer by Event” node.
- Drag red wire out of the “Event” input of “Set Timer by Event” node and search for “AddCustomEvent”.
- Rename “Add Custom Event” node to “LoopingCustomEvent”.
- Plug one of the Current Destinations into the top green input of the Integer + Integer node, and do the same for the other.
- Create an Array Length node.
- Bring in the “Array Destinations” vector array, and select “Get”.
- Connect the Array Destinations node to the squared input of the Array Length.
- Bring in four Current Destination nodes and select “Set” for all four.
- Connect the “True” of the 1st Branch into flow input of the first “Set” Current Destinations node.
- Connect the “True” of the 2nd Branch into flow input of the second “Set” Current Destinations node.
- Connect the “True” of the 3rd Branch into flow input of the third “Set” Current Destinations node.
- Connect the “True” of the 4th Branch into flow input of the fourth “Set” Current Destinations node.
- 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.
- 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.
- Connect the green output of the Array Length node to the input of the third green SET Current Destinations node.
- Go to the game’s viewport and drag and drop pawn into scene.
- In the Details panel, under Pawn, change “Auto Possess Player” to “Player 0”.
- Create a new Game Mode class blueprint and double click the icon in Content Browser.
- 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).
- 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: