How do I make item pick up prompt widget and interactable items that go to character sockets work together?

I’m having trouble making these events , interfaces and widgets communicate with each other. I’m pretty new to UE BPs and im no programmer so a good breakdown is appreciated.

BP_Item is suppose a universal BP many items in the game , both weapons that go onto the character sockets as well as key items/consumables.

The F key I also want to be able to interact with everything in the game so I plan to branch it for dialogues , picked up notes etc.

But for now Im having trouble making the basic pick up item prompt work.

Basically the flow is

Player > Interact Prompt on item with F key > Item pick up prompt YES/NO widget > Plays “Item Obtained!” Screen widget > Destroys actor of item BP > casts BP_Item Skeletal Mesh to player socket.

Somehow it does not go thru after clicking the YES/NO buttons. Also my screen pauses when I press F on the BP_Item again.

Here’s the breakdown , some codes are incomplete here and there please excuse.

Character BP: F key pressed > triggers Interactable Interface event.

Item BP:

Item Pick Up > prints custom dialogue string variable whatever the item is > YES / NO widget

PickupItem Widget:

YES > unpauses and shoots to “Item Obtain” Interface

NO > Unpauses and goes back to gameplay.

Item BP:

Event Item Obtain > same function as Item Pickup screen but then destroys Item BP actor and theoretically should cast item to player BP socket, then close widget and unpauses.

Please this has been driving me crazy cause I’m stuck. Help lol

Hey @Cedirvin! Welcome to the forums!

One of the first things I noticed is this:
Think of “Remove From Parent” as the Widget version of “DestroyActor.” You can’t count on any code after that point to execute:

Like here, you shouldn’t destroy before doing anything based on that Actor, because after that the reference is null due to the actor not existing anymore.

Also, I’m not sure what you’re doing here with casting, you didn’t show that part of the code. Casting is “Make this more generalized thing function as the more specific version of itself.” So you could pass in “Actor” and cast to “Character” to get the actor’s Character Movement Component- if the passed in actor isn’t a character it will fail, and if it is a Character then you have access to anything a Character class has, whereas without casting you couldn’t get that Character Movement Component because “Actor” class doesn’t have one.

Hope this helps! :slight_smile:

Hi!

I tried switching the nodes but it’s still the same. I click Yes button and it unpauses and ObtainItem widget doesnt appear. Also still pauses game without “Pick up item?” widget showing anymore afterwards.

For the casting, I don’t really know where to stick it in the code yet. In the tutorial I found its in the Player BP at the end of the F key trigger , but I want it to go through item pick up widget that asks them if they want to pick up YES/NO before casting the SK Mesh into Character BP socket.

The flow should be:

ItemPickUp Widget:

On Clicked YesButton> unpause > shoot back to Item “Obtain Interface” Event.

Back to Item BP:

Event “Obtain Item” > print string to dialogue widget > “Obtained (Item).” > OK button

ObtainedItem Widget:

OK button > unpauses game and removes all widgets.

Here’s the Cast code + construction code for Item BP:

Sorry if this sounds really complicated.

Honestly idk why I find this so complicated for such a simple thing to do in game :melting_face:

literally press F > wanna take item Y/N ? > Y> you got item! > put item on player hand/inventory

Let’s take it one step at a time.

For testing, let’s use a tried and true oldie-but-goodie. Printstrings!

Just throw some printstrings in between the nodes to find out where the issue is! Start broad, if the string gets triggered, you can remove it, and get more specific by adding them before the first non-fired string! Then you can determine the exact node that isn’t going off.

1 Like

Heya

Great news! I managed to finish my code for the item pick up + prompt widgets.

Thank you or the Print String suggestion I should start making it a habit to use them more often.

I figured out that the “Item Obtain” message is the one that had a problem and realized I might have been using the wrong “target”

So I used the same logic with the F key trigger that detects collision and added it. I realized it needed a trigger as a target. or something like that.

I also managed to figure out how to shoot back to the character BP to initiate a cast to > player socket

I made a new interface function that creates the “Equip Item Pick Up” event.

below are the codes that proceed after clicking “Yes” if you’re interested in how I did it.

Might not be the most sophisticated or cleanest way to do the code for such a simple thing in game. But it had me really inspired. I’m planning to tackle a note reading code and a full on inventory system that will link up to these.

Thanks so much!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.