Hello, I am currently designing an exploration based game where the character has to find notes that guide them to their objectives. I want to be able to hit an interact button that destroys the actor and shows the text. Then when the player is done with the text they can add it to their journal for further inquiry. I’ve tried creating my own inventory system, but its not really the feel I want for the game. If anyone can help that would be awesome.
make a structure with a string variable called NoteEntry, then make a data table out of that struct called NoteData. in the data table, add a new entry for each page of notes in the game.
then make a widget called NotePage, with an image that looks like paper, and a text widget. bind the text widget to a text variable called DisplayText, which is set to editable and ExposeOnSpawn.
then make an actor called NotePickup, with a box collision component set to overlap only pawn and a static mesh component, which can be an imported FBX model that looks like a piece of paper. make a name variable in this actor which is set to editable, and every time you place one of these actors in the world, you have to set this name variable to match one of the entries in the NoteData data table.
on the box component, override OnComponentBeginOverlap, and cast the other actor into your custom pawn type, and then you can call a GiveNote function in your pawn, which should use a name variable as an input to the function, then the pickup can call destroy on itself.
inside your custom character/pawn in the GiveNote function, you should use the name to access the data table, which should return a string. then create a widget of type NotePage, pass in the string, then store the widget in a UserWidget variable, and add to player screen. when you want to remove the note, you can use RemoveFromParent on that UserWidget variable.
you should probably also have some way of keeping track of whether a player is currently reading a note. you can use a boolean called bIsReadingNote inside your player controller or character, and whenever you detect controller input events, you can branch on bIsReadingNote. if its true, any button removes the widget from parent and sets bIsReadingNote to false, and if its false, you can do normal character input for walking around.