Im currently working on my first game and I’m looking for a bit of help on one of the systems. I’m still new to UE so there’s a chance I won’t be able to implement this system in my game, but I’d like to try anyway.
I’m looking for a way to do the following things;
scan a box in game and have the device give you a shelf location
place the box on the shelf and if it’s in the right spot, not be able to pick it up again
have a designated spot to bring a pallet of boxes and complete the objective when it’s in the right spot.
If anyone can give me an idea on how to implement any or all of these, please let me know.
For scanning, you can have it get detected once the player enters an area using collision boxes. Or if you want the player to search for it, you can use line traces and get the hit actor. (Don’t forget to use the “Is Valid?” node with the question mark in that case) Whatever way you choose to detect the actor, you can always give it an actor tag (be careful to set it to be an actor tag) and read it’s value using the “Actor Has Tag” node, and move on with the correct algorithm for that specific actor that way. Use the same tag reading mechanic to check if it’s in the correct spot by plugging it after the “On Component Hit” nodes that detect collision for certain places with collision boxes that you can place on the desired locations. Or you can just check if it’s on the correct location with a margin using the “== (vector)” node. Once it’s placed, you can have a bool type value that gets set to true and bind that before your picking up mechanism by using a “Branch” node and plugging that into the condition pin. Hope this helps!
Thank you. So, if I wanted the player to be able to walk up to a box, scan a ‘barcode’, and then have the scanner give the player the shelf location, how would the setup go? I tried it this way; set up a line trace and branch in the player blueprint to check if the box they clicked on is scannable, and if it is, return the shelf location, and if not, give an error. I had isScannable? boolean in the actor blueprint class so I could have it instance editable, but I couldn’t get it to work. Is it it possible to do it this way?
Can you first try to implement this using blueprints? I usually do that since unexpected things can happen with C++ and this specific task you want doesn’t really need to be divided between C++ and blueprints. If it’s necessary though, you can move on with that later, but first make sure what you wanna do works in blueprints. If that doesn’t work out either, send some screenshots of the blueprint as I can’t say anything much without seeing your code
You already got that addition node but why didn’t you plug the world location to the empty pin?
Also you can use the “Is Valid?” node with the question mark after you perform the line trace and plug in the hit actor into it’s input object pin to be safe.
As for the main reason why it’s not working, the bool type variable never gets set to true in the screenshots you’ve sent, how can it execute the true pin of your branch?
I guess it kind of overlaps in the screenshot but the world location is connected to the add node as well as the start of the line trace. And for the boolean, I have it set to be default false and instance editable so I can make some actors in world scannable and some not, does it not work that way? Is there an easier way and I’m just way overcomplicating it?
Yeah but from the screenshots provided, I couldn’t see anywhere where it’s set to true. Can you clarify what exactly doesn’t work, like where does your execution reach until it doesn’t run the parts you want? Since you didn’t specify these and just said it doesn’t work, I assumed you meant it doesn’t get past that branch node. If that’s not the case however, you could elaborate further and send the other related parts of your code
It all ‘works’, unreal doesn’t give any errors or anything, but the actor isn’t actually instance editable. So, even though I have it set it be, it doesn’t matter whether the instance boolean isScannable? is set to true of false, only what is set in the blueprint. If I set it to true, its always true. I’m doing all this in a separate project because I don’t wanna mess with the actually game until I can get something that actually works. Would it be better to do it with an interact interface?
I understand like you want to give different actors different “scannability” attributes. Why don’t you try using tags? Just add tags to your actors but make sure they’re actor tags then use the “Actor Has Tag” node to determine if they are scannable or not