I’ve been working on a small game to get to grips with the basics of UE4, as its been a long time! The main mechanic is point and click style investigating.
For my player I added a function that raycasts outwards from the player’s height and rotation, then returns whatever object it hits.
In the event graph of the player, when the lmb is clicked, it checks if any UI exists. If it does, it removes it. If not, it runs the raycast and if the object that is hit is of the interactive object class, it runs its on use function.
The on use function in the interactive object creates a text display UI and sets the text of that UI to equal a text variable that lives in the interactive object.
All interactive objects are child blueprints of this, where the clicked text variable is overridden.
For more specific mechanics, I’ve still used the same parent class, but overridden the on use function. For example here, when the computer is clicked on it checks if its been successfully used, and if not shows a text input UI. If the password has been successfully entered, it shows the normal UI text display.
The text input UI has its own event graph, which when the password is entered correctly, will find the door asset in the level and run its unlock function.
The unlock function rotates the door when its run, allowing the player to leave the room!
This is all very simple stuff so far, but its been interesting to take a look at.