How can you make your player pick up and read a piece of paper?

You can easily use a cube or sphere trigger component and on an overlap event in item blueprint to draw the texture to the hud. If you want optional pickup functionality it gets more complicated from there and those questions have been answered elsewhere.

Sorry for the questions and everything. I’ve looked everywhere and tried a lot of things but nothing seems to work. what I would like is pretty much you walk up to an object (in this case a piece of paper with a note on it) and you’re able to pick it up where you can either read the object itself, or have text appear on the Hud and you can back out of it at anytime. Either option would do. And then put the object back where it was, in an inventory (Which I haven’t figured out how to do yet, but still trying) or destroy the object.

Pretty much the sequence in any survival horror game with a note or letter.

If you can, A blueprint would be nice. but if not that’s totally fine as well! :slight_smile: Thank you!


You can set up a raycast for when you press E. Have your Actors that you want to read have an actor tag that says something along the line of Read or Interact. After the ray cast hits it break the hit results so you can get the actor that you hit. Then using the actor that you hit you can use ActorHasTag and see if it has the tag you set for it. It will return a boolean value. You can then use the boolean value to whether or not to run a function, for instance displaying a widget to the player.

If you want to transfer the data from the widget to the player, you can se up a BP interface for interaction and add it to the actors settings. So once in your player BP if that actor happens to have the correct tag, you can pull off of that actor pin and send a message to one of the functions from the interface. Then inside of the actor you can have said function destroy self so it disappears from the work.

I’ll throw together a quick demo with screens in a minute to show you

Okey dokey had my coffee and wrote some code for you.

what you will need to do:

  1. Create 2 Widget Blueprints(one called Journal_BP the other called Journal_Slot)
  2. Create 1 Blueprint Interface with 2 Functions inside of it
  3. Create a base Actor Blueprint which will be the note to be picked up in the world, with one variable that happens to be set to Text. Then, under the class Defaults, go to the bottom of the list and expand the Actor section. Create 1 tag and set it to Journal. This is important.
  4. Inside of your Journal_Slot, under the designer tab, delete the canvas panel that is present so it no longer has set bounds. Add on 1 scroll box, and inside of that scroll box then add on one Text. Make sure the text has the auto wrap box checked so it will wrap inside of the future bounds in you Journal_BP later. Bind the text to a function, and under that function just promote the text in the return node to a variable, name it what you want and make sure it is visible.
  5. Inside of your character create a line trace by channel and have it fire off whenever you press a key, whichever key you’d like.(see screenshots if you need to know how)
  6. Off of the Out hit pin on the line trace node drag off and type break hit results.
  7. Drag off of the hit actor and pull up an ActorHasTag node. Type in Journal, this is so it can know if the actor is supposed to be interacted with in this specific way.
  8. Now, in your Interface that you made, one of the functions should be called Destroy Action and leave it at that. The other should be called Get Text, with 1 output, set to Text type.
  9. Back in your Raycast, pull off of the return value for ActorHasTag and get a branch. Drag off of the Hit Actor one more time and type in Get Text. Thye option for Get Text(Message) should appear and choose that.
  10. Create a variable in your character Blueprint Set to the Text type, and make sure it is an array and that it is visible. This is for that Inventory option you asked for. It won’t be in an inventory, because that’ll be a lot more work I’d be happy to help with but too many screenshots and Blueprints for the page.
  11. Pull that newly create Array into your character BP, drag off and type in insert. This will insert whatever Journal entry you just picked up to 0, the first entry, so when you bring up your journal screen it will be ordered from most recent to oldest.
  12. Now pull off of the hit actor again(from the break hit results) and type in destroy action. The option Destroy Action(Message) should appear. Choose that.
  13. Now in your Actor Blueprint for the Item in the world(same one you set the interface for and the text variable), under the event graph, right click and type in destroy action. The option Destroy Action should appear as an event. Pull off of that EXE pin and type in destroy actor, leave the target to self.
  14. Now, Final steps. Open up your Journal_BP, your main journal Screen that hasn’t been touched yet. Get a Get Player Character node, drag off and Cast to FirstpersonCharacer(Or whichever BP your playable character is based off of). Drag off of the AsFirstPersonCharacter pin and promote it to a variable for later use in case you need it. Connect the event construct to the Cast Node. Now drag in that character variable you just promoted to 5 star general and drag off of it to Get (whatever you named your text array inside your Character BP) and promote that to a variable, Just for use and ease later so you won’t have to repeat this step.
  15. Add a custom Event, Name it ConstructJournalEntries. Off of that drag out and get a Create widget node. The classs should be set to your Journal_Slot. Drag off of the Return Value and promote that to a variable, again for local use. Drag off of the newly create variable and Set Text. This is setting the text variable that you made inside of the Journal_Slot.
  16. Now, in the designer, place down 2 buttons wherever you’d like, a vertical box wherever you’d like(this is where the text will be read), and a scroll box inside of the vertical box, make sure it is set to be a variable, and set to fill, so it takes all the space in the vertical box.
  17. Now back in the graph, drag off of the set text nod and type in Add Child, the target should be your scroll box, which should be visible in your variable panel if you checked the box in the designer, and the content should be the variable that you set the text for.
  18. back at the end of the Event Construct node, after you’ve set the local array of journal entries, drag off and type in the name of the new event, ConstructJournalEntries.
  19. Now, back at the ConstructJournalEntries you still need to know what index of the array you want to show, so create a new variable, of Integer type, and have it set to 0 by default. drag in the localJournalArray you promoted at the beginning, drag off of that and type Get, then for the index number it wants connect your new Integer variable. Off of the Get node, drag the pin to the Set text input pin, so now it knows what text string should be placed there.
  20. Back in your designer get an OnClicked event for both of your buttons, one for Previous and one for Next
  21. Off of both of them, drag off and type in remove child, target should be the same scroll box and the content should be the local journal slot variable you promoted earlier. This ensures that when you click either of these buttons it will clear the previous journal entry. another note these should be in separate commands, not both button events tied to the same remove Child node.
  22. On the Next button line of events drag off and get a branch, do the same for the previous button event too
  23. for the Next button events, get your Integer variable you made earlier, and get your local journal array again. Drag off the array and type length. Drag off the integer and get a >=(integer) node. connect hat to the top and the Length to the bottom. drag off the return value and type NOT for a not Boolean. and connect that output to the Branch
  24. For the previous, just use the integer and get a >= node again, but set the bottom value to just be 0
  25. Now off both of the branches true nodes for both buttons, get a sequence node with two pins only
  26. off both of the first pins drag off and Set your integer. for the Next button it will be you Integer +1, for your previous it will be -1.
  27. Drag in your localJournal_Slot variable again and drag off the pin twice and Set Text. Connect the second pin from the sequences to these two Set nodes. Drag in your integer varaiable again and your array variable again. Type in get off the array variable, you’ll need two of these nodes. connect your integer variable to both of those Get nodes, and then connect the Output from the get nodes into the Set Text nodes. Using your scroll box variable Drag off and type Add child, again, twice one for each path
  28. connect your scroll box to the target and the local journal slot to the content
  29. Now that that is all done in your character BP just set, lets say Q to be the key to open the widget.
  30. So off of the Q Event pressed node type in flip flop. Off the first pin type in create widget, set the class to be your Journal_BP. Off of the return value drag off three times, the first being Add to Viewport, the second being Set input mode to Game and UI, the third being remove from parent.
  31. Get a get PlayerController node, and off the return value drag off 4 times. the first time plug it into the Set INput mode to Game and UI, the Second time Get a Set Input mode the Game Only node. And the next two get a Set Show Mouse Cursor Node, set one to yes and one to no.
  32. Now connect the Create Journal → Add to Viewport → Set Input mode to game and UI → Set show mouse cursor YES
  33. for the option B on the flip flop connect to the Remove from Parent → Set Input Mode Game Only → Set Show Mouse Cursor NO

Go ahead and try everything out, duplicate your Actor Blueprint for you note and then change the text value to whatever you want to have multiple notes, or Use it to create a Parent class, but that’s different and another thing all together. If you have any questions or want more of an explanation just ask I’m happy to help

Thank you so much for this! I think it all works! Just one last question, I would connect all this to being able to pick up the note by making an actor for it and putting a trigger box around it then using a key to add it to the journal? I’m sorry if I’m not making sense and i’m also sorry that i’m relatively new to Unreal Engine 4. So to be able to look at an item, press a key to pick it up and add it to the journal to read that is what I should do? Again, I’m sorry for asking so much

No no, you wouldn’t need a trigger volume, as long as the mesh has collision the ray cast that was set up just has to hit it, if you want to see where the hit is going on the ray cast select the drop down menu for debugging and select persistent

Okay I seem to have gotten everything right I think, the only thing is that it is not picking up. I posted the pictures of what you’ve told me to do and made sure the mesh has a collision. If you see any errors in there that you find please point them out… I triple checked it, but maybe you will see something.

In the first screenshot, with the line trace you need to have values set for the start and end, I have then set in one of the screenshots I posted, you can also find another way in the UE4 docs just search for line trace or ray cast. In the Actor blueprint that the destroy action is being called in you need to make sure in the event graph you call the EVENT, it will be a red node alot like the event begin play. Also from your line trace node in your character BP the exe pin from needs to be connected into the branch. It all looks good besides those things, without the line trace having a distance it wont know how far to go or where to start, and without the event destroy action being fired in the actor it wont know to destroy itself

To be more precise look at the first and second screenshots I posted, on the right side graphs, I screenshot two of my montors, so in this case the right monitors. The top screenshot has what the actor being destroyed should look like, and the middle/second screenshot has the character BP with how I set up the starting point and distance of the ray cast. There is one small thing cu Lt off in that image and that happens to be the player gamer, you can drag that in from your components in the BP. It’s getting the first person camera’s forward vector, setting it to the started point, then it is adding some distance to it and setting it as the end point

Player camera sorry not gamer, I’m typing on a phone and auto correct makes fools of us all

On the second screen shot on the right what is that one to the very left thats hiding?

Figured it out! Thanks so much for your help!

I’m about to follow this guide so hopefully I wont be pestering you much but straight off I want to say thank you, this is amazing.

No clue if this will see a response but the DestroyActor event does not appear when I try to add it.

@MrAdAbsurdum

Hi, thank you so much for this tutorial. Unfortunately It do not work for me… I carefully followed the steps but when I press the key I assigned before (P) I’m only able to see the Previous and Next button. When I click on it nothing happens and I don’t see/can change any text…

Could you please help me? Your system seems to be great and I’m new in the world of UE4 so many thanks in advance for your help !

If needed I can upload my blueprints.
Sorry fo rmy english !

Many thanks in advance

You just let us download the entire Blueprint.

Sorry but i am totally cannot find how to do that… can you help me please?

Thanks!