Download

Interactive BP Pickup not 100% working with line tracing and casting to player character.

Good Morning All,

Have a problem I’m having a brain fart with. For the life of me I can’t get this one simple thing to work. As usual, done Googling searching as well as Forum searching, and tutorials. I am setting up a Shop scenario. You have a wallet and I have them starting with X amount of money. I have a pickup which I call the lucky ATM and it randomly will add to your wallet, sometimes, as I’m cheeky, you may get $0 and the ATM does go away and comes back after a period of time. This is working beautifully. To get the initial idea to work I set up the pickup with a trigger to the item and an Event Begin Overlap with the trigger. What it then does is cast to the player character to check how much money is in their wallet. If they have enough for the item they will collect it, it will take the money from the wallet and update it. If the player doesn’t have enough money it will then display the wallet showing them just how much is in there for X amount of seconds, then disappears and won’t allow you to pick it up unless you have enough funds. This works beautifully!!! So then I went to phase 2 which is adding in interactive functionality.

So for Phase 2 I simply created a line trace so the player can detect the item, I have it connected to an interface to say “Hey yes this item uses such and such interface, now interact with it.” So when it does detect the item can be interacted with it draws a UMG HUD that just says “Press E to purchase.” Now this does work…without the casting and check of the wallet side of things. It I simply change the BP to have a simple Event Pickup Item → Print String “Item picked up” → Destroy Actor it works. No dramas at all. The moment I remove the Event Begin Overlap in the pickup masterclass and connect it to the Cast to Player, run the checks yada yada it is failing. Now I suspect it’s my Other Actor Ref. I simply created a variable from the Event Begin Overlap’s “Other Actor” and plugged that into the Object of the Cast to Player. I was unable to use any of the components of the BP class to connect to the cast node. Hence I suspect it’s this. I have included a screen shot of the pickup class, which is the master class and all other shop items will be a child of this and have commented it.

Any advise would be very much welcome. I may end up figuring out what I have done, have done that so many times, but this time it’s got me stumped.

Thanks all!!!

Regards
Shez

Am I right in the assumption that you only (your player character only) should interact with the overlap? If yes, just right click and type “Get player character” and put this node into your cast “object” node. If you are the only character, which needs to interact with your overlap, this would be the easiest solution :).

DarkGodsLair you beauty!!! I’ve been a C++ programmer for many many years, like over 20…and why the bleeding heck did I not just do that…I mean duh I do it a zillion times!!! It drove me nuts so thankyou so much you are a legend!

Regards
Shez

Glad to be of help :). Well it is strange, how we end up getting stuck on the simplest of things… But this happens to most people (including me), especially when I need to check simple checkboxes :).