What is more efficient? Line trace or collision volume?

Hello everyone, I am making a door blueprint, where if the player is within a certain distance, they can open the door by pressing a button. There will be several hundred doors. My question is this:

What is the most efficient ways to do this? Here are my possible ideas:

•Do a line trace in front of character 4 times per second, and if there is a door hit, display that they can open it, and if they press the button, open it.
•Have each door do a line trace, and if it hits the player, let them open it.
•Have a collision volume, and the player can open it when within volume.

I am guessing that doing a line trace in front of character is most efficient, because then I can also turn cross-hairs red when enemy is in front of screen, but I’m not sure. Any help is appreciated!

I would do it with a trigger volume. Not sure if it is the most performance efficient, but it seems simpler and more elegant.

But if you need to check other stuff with your line trace, then extending that could be best.

Have a collision volume and after that start doing the line traces to see if the player is facing the door. When the player is outside the volume, stop doing the line traces.

Once the player is inside the volume you don’t have to do traces to check whether they face the door, you can just compare their forward vector with the door’s forward vector like this: Abs(PlayerForward.Dot(DoorForward)) >= 0.8.

You’re making a first person game, is that correct? Since you mentioned you will be doing line traces already for other features, then using the same traces to resolve doors sounds most efficient. Do you need to AIM at the door to interact with it? So I mean with the cursor, not just general direction. If so, one more reason to do a line trace.

Yes, I think that is what I will be doing, plus I know that just the existence of a lot of spawned actors bogs down FPS even when their not in sight, so that’s what I figured is the case for a bunch of doors with collision volumes.

Actually, hundreds of doors with collision volumes isn’t even a problem if you set up their collision profiles in a smart way. You can set up the doors to only check collision on the “Pawn” channel, so that it only checks collision with pawns. If you have multiple pawns and only care about the player, you can create a separate “PlayerInteraction” channel and let the player pawn be the only object on that channel. This all reduces the number of collision checks that are performed.

I think the trigger volume idea is better for example for third person games, since then line traces from the character are less useful for other features.