I use a long rod mesh as a child to the head socket of the character BP as a collision object. It’s very thin and effectively acts as a line trace. When this collision rod overlaps with the item mesh, it does something.
What? I duplicated the pistol mesh and only gave it a glow material. It is made visible whenever the overlap event fires and hides it again, when the overlap concludes. This all works and I implemented this directly in the item event graph.
But now, that items glow when I look at them within 3 meters, I want to be able to click E in order to interact with the item.
I basically need a method, that makes the E key available only when I focus on that item. So, I thought of having the input action in the item event graph, but am at a loss as to how I proceed. Does anyone have an idea without casting?
So, I thought of having the input action in the item event graph
That’s not the way.
That’s what tracing and interfaces are for. If you already have a reference by using your makeshift rod approach (why, though? - why not trace?), skip the trace and send the message to the item.
Plenty of tuts on YT. Also:
Already does this:
I duplicated the pistol mesh and only gave it a glow material.
But in a more efficient way - tuts on YT, too.
I use a long rod mesh as a child to the head socket of the character BP as a collision object.
Not sure why you opted for this, but do consider not re-inventing the wheel and making it square. Tracing & Interface is the standard, the most efficient combo for this.
I disabled the item event graph and migrated the shenanigans to the 3rd person BP as shown above.
Now, I found a way to trigger the line tracing for the duration of the overlap. It’s not necessarily the original question, but I consider this the preworkout to eventually get to the actual question. I’m going to fiddle with it some more, as the line trace hits the collision sphere of the item instead of the mesh. Ignore the nodes for the print. I just tried to find a way to get some debug message, but I have to figure it out
The question is how I do this overlay thing now. How do I get the pistol instance to modify the overlay?
EDIT: Fiddling with it for quite some time, I realized, it’s even more complicated, as the character might be inside the reach of multiple items simultaneously. So, the simple “enter bubble → set variable to true” method might not be that robust and I might need to work with an array of all the bubbles the character is currently overlapping with. That sounds fun
Sooo, I find myself in a binge, it seems. I hope it’s not a straw fire.
Anyways, I have actually found not yet a solution for my question, but I’m working on it. I have now found a way to basically put every item in range (not yet the focus, only the “focusable” range) in an array and remove every item again as soon as it gets out of range. I found this very helpful and it was not as hard as I feared, which might explain my motivation:
Here, so far, I basically took advantage of the array I now got of all items in range in order to sort out all hits, that are not these items. I removed the old bool variable to check if the overlap event has triggered, since I wasn’t sure how it behaved with mutliple overlapping items in range. So, I discarded it and used the array length as the prerequisite. And only if what I look at is one of the items in this array (is one of the items in range), will it debug-print. So far, so good.
I’m almost finished with the pre-question workout. The only thing I now still need, is to activate the overlay material onto the item I’m looking at. So far, I’ve found no solution for that, but the night is long.
I have been laborous and finished the pre-question things. I even learned how to communicate with interfaces between blueprints. I now have full functionality about making items glow on hover while in range:
What it does, is: If the amount of items in range is higher than zero, & if the hit actor is one of the items, then, I use an interface to get the thread going in the pistol BP, where the item is made to glow golden.
But if you don’t look at the item anymore, the outline glow ends.
The result as far as I can show, of course:
I think I am one step closer to an
swering my own question. I now accomplished that the character can interact with the item and the item is destroyed.
I added a bool variable to the end of the node chain I showed above:
This variable is checked in my “click E” interaction. Only when this variable is true, does the E button do something, via a branch node. The object is then destroyed.