Clickable Interactive Objects in UE4

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.

334babaf56e7007d851cc59060337a01

Player

For my player I added a function that raycasts outwards from the player’s height and rotation, then returns whatever object it hits.

1

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.

2

Interactive Objects

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.

3

All interactive objects are child blueprints of this, where the clicked text variable is overridden.

5

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.

6

87bf37013b0194ac934aa8a2576f4c6c

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.

7

The unlock function rotates the door when its run, allowing the player to leave the room!

4

This is all very simple stuff so far, but its been interesting to take a look at.

 

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s