Alrighty, let’s break it down per blueprint. I’ve got a few questions on each and a few edits on each! I’m gonna critique you like I critique my students because that’s the only way I know how, so I hope I don’t come across as condescending or insulting. Without further ado, let’s do it.
Level BP - Why do you set the player character’s location to be the player character’s current location? I mean, on Event Begin Play it really won’t hurt anything but I’m curious if there’s something I’m missing as this doesn’t really do anything to change the game. Additionally, what do you use the “Delta Seconds” float variable for? Do you have any other logic on your level bp? If not, you can delete that portion of the blueprint since the variable will only be visible by the level bp itself and it’s doing this every Tick, so you’re throwing unnecessary overhead into the works. The only thing I’d keep personally is the Set View Target with Blend node because it’s easier to reference a Camera Actor from the level bp but even then it could easily be done in the Player Controller. As you can tell I’m not a fan of level blueprints
(Side note on level blueprints, when I first started with Unreal I used the level bp a lot too. It worked out great for a while until of course I wanted to change maps. Then I either had to recreate all of the variables in the new level bp because copy and paste only copies the nodes, not any variables or functions, or move everything out of the level bp and into a class blueprint. Now I just avoid the level bp whenever possible and use it only for temporary stuff like spawning a widget or something until I have all of my ducks in a row. Perhaps I’m just a jilted ex-boyfriend about them but I’d strongly recommend against using them. /rant)
Player Controller - So the reason your foreach loop isn’t working here is because the loop only keeps the object in memory during the loop body. When it’s completed, it doesn’t pass an array element. Every UObject (the base class from which all actors and Widgets inherit from) has a function called “Get Display Name.” What you’d want to do is execute print string every loop body and Get Display Name from the array element, plugging the return value from that into the print string node.
Debtor BP Begin Play - Like your level bp, you’re setting your pawn’s position to be its current position. There may be a reason for this, but I just don’t know. Instead of using the variable you created for “debtor” you can just use “Get a reference to self” to ensure that you’ll always be referencing the debtor and won’t end up with a broken reference. I say this because there doesn’t seem to be anywhere that you tell the engine what the debtor is. Lastly, you make a Current Tile Array twice, once in the Player Controller and once here. You only really need one and you can reference it from the other blueprint. It probably won’t hurt performance much to have two arrays with the same information, but it does take up unnecessary memory. I think the pawn works better than the player controller for that since the Player Controller never references the current tile while the pawn references it a lot, so you can save yourself the overhead of Get Player Controller->Cast to My Player Controller->Get Current Tile Array.
I would have begin play be like this (this pic is missing the part where you populate the current tile array; this should come after that):
Just set the tile index you want to start with (which this assumes to be 2 on every level) then set your debtor’s location to be the location of the tile plus your pawn’s Z box extent. The box extent is the distance from the center of the actor to the very top of it, or its half-height. You can open up structs (a vector is a struct of three floats) by right-clicking on a struct pin and choosing “Split Struct Pin.” I do it this way in case you ever need to change your pawn in the future. It may never happen, but it’s better to be prepared for any contingency, in my opinion.
Debtor Press Right - Unless you will have no more than 7 tiles in any given scene, you should make the branch check more like this:
So now it will check how many tiles there are in the scene, subtract 1 (because arrays are 0-based) and will only then move if the current index is less than the last index.
You can also use the “Last Index” property on the array which is the same as Length - 1, I just didn’t think of it when I took the screenshot. It isn’t a thing in most programming languages, it’s just a nice blueprint feature.
Debtor Press Left - This looks great! The only thing that jumps out at me is that you’re setting the current tile index to be itself +1 every time the Timeline updates, so depending on your frame rate you could end up with a current tile index of over 60 after a second.
Debtor Both Presses - This stuff applies to both press left and press right. You should increment the current tile index right after checking the branch. This way you are sure to do it only once and you won’t have to add or subtract from the current tile when you’re getting the tile’s location. Also the do once macro isn’t really needed if you’re resetting it when the key is released. Pressing a key down only fires once for each time you do it; it isn’t continuous. Do once is great if you have to do some logic on Tick or something but you only want to run it one time or if you only want a button press to trigger something one time, not multiple times.
As for your other post, I’m not sure exactly what the problem is without seeing it. Can you post a screenshot of the error tooltip you get when you hover the pin over the other pin?
A few ideas that come to mind that may or may not apply: Arrays can not plug into single pins, only array pins; use a get node if it’s a single pin. Alternatively, if you have an array pin already plugged into another array input pin, cut the connection, then try to plug in another array it will not work because it’s still listening for that particular array. You’ll have to recreate the nodes in that situation.