OnBeginOverlap replacement?

Anyone know any replacements for OnBeginOverlap because I’m currently using it and its causing isues. I’m using it to see if a player is close enough to pickup an item but when I have two items on each other and I try to pick up the first item it picks it up but then when I try to pick up the second I can’t and I have to first get out of range of the pick up to be able to call OnBeginOverlap again.

Any suggestions would be appreciated and thanks in advance.

Yes, line trace :slight_smile:

For some reason ( no doubt a youtube vid ), there’s this tidal wave of people using overlaps for interaction. It is not a good method.

One of the downsides you’ve seen. Another is that you can interact with things with your BUTT!

Line trace is the way, you can only interact with something if you’re looking at it ( or a component of it ).

2 Likes

Line Trace is great, but it depends on the type of game. Let’s say it’s a slasher with no crosshair: it’s not going to be easy to hit small objects with a line trace, and if you add larger invisible colliders to them, they may overlap and we’re back to the initial problem.

One example I can think of is Blade of Darkness. I think how it works there is characters have some king of a trigger attached in front of them, and it highlights objects that are overlapping the trigger and can be interacted with. There’s a separate key binding that cycles through all the available objects, highlighting one at a time. It’s a neat solution, as for me, where you don’t have to aim at anything.

2 Likes

Yes, it really depends what sort of interaction…

Personally I use shape traces (line traces can clip through object seams if the collision boxes don’t fully block out stuff like wall pieces, and considering Epic’s FBX guidelines advocate for leaving small spaces between colliders, you will likely have gaps). The first trace is small, and if it doesn’t hit anything, I do a bigger trace, and finally, the biggest trace. That way the object the player is looking at should be the one most likely to be highlighted.

If you have some other kind of gameplay where the player doesn’t have a clearly controllable camera viewport to target at interactable objects, like a top-down game without a mouse cursor, I would just store the interactable objects in the array and prioritize the object the player has the shortest distance to. If player interacts with an item and it disappears you can then still see if there’s something left in the array.

Imo iff its not an fps, overlap works fine for this. You just need to add the items to an array and select the closest one per every button press or all if prolonged press (like in Sekiro).

Or… activate widget on overlap and use line trace as said above.

One replacement is get overlapping actors from your player character. Whenever you overlap two pickups, press interact input key and call “get overlapping actors”, connect a “for each loop” to the array output, cast to your pickup actor BP and execute your pickup logic if the casting succeeds.

Keep in mind that the “for each loop” node will pickup all interactables nearby player. Now, if you want to pick one by one for every input press, instead of using a “for each loop” node, get a “get array element”, set index to zero then cast to your pickup actor BP, and execute your pickup logic if casting succeeds.

1 Like

dunno if this will help, but here is a way that I use overlap and line trace together in my project:

for a very simple AI detection system, I have a sphere collision set to overlap with just a single custom channel.

When the player pawn overlaps it will send an interface call to the owner of the collision. Then the owner will start shooting a line trace to the player pawn to check and see if there is line of sight, what the distance is, angle, etc etc. ALl of that information you can get from the line trace but not from an overlap.

On end overlap will tell the timer shooting the line trace to stop.

I use the overlap basically as a way to toggle the line trace on and off rather than having it go constantly, or otherwise using tons of line traces to sweep a large area.