The standard way to do it is with a line trace and a blueprint interface.
That way, you can walk up to anything, do a trace ( which is the equivalent of the player trying the object ), and check if the object implements the interface.
If it does, you can send it a message saying ‘I touched you’ or ‘I operated you’. It’s up to the object, in this case, a door, to decide what to do with that.
A door would open actually, but you can teleport the player if you want.
So you setup the blueprint interface. In the content browser right click and
](filedata/fetch?id=1821524&d=1602531015)
You just put one function in there ‘Interact’, compile save ( no code ).
The door would look something like this:
](filedata/fetch?id=1821522&d=1602530890)( you need bigger boxes, because the player could interact from a distance ).
The code is:
](filedata/fetch?id=1821523&d=1602530947)And you make the door BP implement the interface like this:
](filedata/fetch?id=1821525&d=1602531145)The player line trace looks like this:
So, on mouse click ( or however you have it set up ) it traces and checks to see if the actor implements the interface. If it does, it sends the ‘Interact’ message to it.
If you need to know more about BPIs I’d recommend this: