For this step of the documentation, I will use the first person template.
If you haven't looked at the Overview page, I recommend you take a look, as here I will skip some steps that I already explained on the Overview page.
We will make two items, a lamp that can be turned on and a key that will be destroyed.
(The items I'm going to use are part of the Unreal engine's "StartContent" , The key I'm using here, I got from FAB for free, search for "Key" in FAB and filter by free.)
But before creating the objects, let's adjust some values to make the system work well.
This step was already mentioned on the Overview page, but here I will go into more detail in the explanation.
So let's start from the beginning.
Click on "Edit", this button is in the top left.
A window will open, click on "Project Settings”
In the Project Settings window, look for "Collision”
In the Collision window, click on "New trace Channel”
Enter the name of your preference, I entered "LookAtObject". Choose "Overlap" in "Default Response".
If this is your case, try to leave this trace that we created now first in the list of traces, if you can't leave it first, you need to change some things in the component.
Let's correctly configure the trace in the component.
Open this component:
Inside the component, you will find the following functions:
Open both functions.
Open any of the functions and find the "Line trace by channel" node
Note that this node has the "Trace channel" input, see if it is configured with the trace we created a moment ago, if it is not, change it to the trace we created.
Repeat the same process for the other function.
Now let's look at the other component, check if the trace is also correct there.
Open this component.
Look for this function and open it.
Let's focus on this logic where the square is covering.
Zooming in on this part of the logic, you will find the nodes in the image below. See if they are blocking the trace we created. If not, adjust them to block the trace.
After that, you can close the components.
Now we have the trace in the correct way for the system to work, let's continue!
Open your player's blueprint to adjust some values there.
By clicking on the component, you will see the variables that we will adjust for the system to work.
See the table below to see what each variable does before changing them:
Input Name | What it does |
---|---|
Base Class to Interact | Irrelevant to this mode of interaction |
Interact Mode Active | Choose the interaction mode you will use |
Is Hold Button? | Are you going to use the button-hold system to interact? |
Select Hold Widget | What the Hold Button Widget will look like |
Hold Multiplier | Set how long it will take to interact with the Hold Button |
Lenght To Check Object | How far away should the player be from the object to be able to interact. |
Lenght To Interact | What will be the distance at which the player can interact with the object. |
Debug Trace Check Object | You can see the lines that check the object, it is very useful for testing |
Debug Trace to Interact | You can define whether you can see the line that will be emitted to interact with the objects, it is also very useful for testing |
Now that you know what each thing does, adjust it as shown in the image below:
Okay, let's continue!
**To create the objects, I will create children of a base blueprint, which is the base blueprint that is included in the Interact System folders.
The base blueprint is located in the "Base Actor" folder, in the interact system assets folder.
Before creating the children of the base blueprint, check if in the base blueprint, the Mesh component that comes by default is blocking the trace we created, as shown in the image below:
**All meshes that are part of the base, or children of that base, must block the trace we created.
Right-click on the base blueprint and create a child of that blueprint.
And rename it to "BP_Lamp", you can do the same process for the "Key".
Adjust the lamp and some light, I used the "Spot Light", if you don't want the Start content lamp, you can use any other static mesh.