Best method for object interaction?

I have a bunch of blueprints that have some meshes in them that the player can interact with. For example a fridge with doors, I call the line trace within the fridge blueprint using triggers, when player is inside the door triggers the input is enabled for player to interact with them. I did it this way because I thought it’d save performance instead of constantly checking line trace when pressing the “Use” button. Is this the correct way to do this or is there some other way? And does this method really increase performance?

I’d like to hear how others have done this kinda interaction
I did try to search for this sort of concept on the internet but couldn’t find what I was looking for

From what I understand of line traces you should be able to set a max distance which would most likely be the most efficient way

A simple Line Trace isn’t that heavy regarding performance.
You probably press the Use-Button once instead of holding it permantently.

Collision Boxes can be buggy if you move too fast and or spawn things directly inside of it.
I’m pretty sure Collision Tests are more heavy than a single Line Trace.

You can download a free example of object interactions in my porfolio: Object Interaction System - Nestor´s portfolio

There are other ways of communicating between blueprints, but for the “user interaction” the normal way is to make a raycast (line trace) each tick, for games where you can interact with multiple objects. If you are goint to just interact with some doors ocasinally, you can go your way.

PD: Using volumes with triggers probably will end with poor performance than making a simple raycast each tick if you have multiple interactable objects.

Grts,

  • Nes

Thanks for the tips. I’ll check out your portfolio Nesjett.

But how I have my objects is that some doors/objects might never get opened or interacted with. So I figured maybe I’d do the check only when player is near them. I did change the collision volumes to a sphere on the fridge for example. At least to my knowledge checking sphere radius for collision is faster than checking collision for a box

Im not sure about the thing you say about sphere or box collision, but both methods are way more expensive than a raycast from your character.

Cheers :slight_smile: