Download

Line trace to trigger interface event which teleports the player.

Ok, so I have been working on a horror game for a while now and I have it to where doors never open but instead the player presses E and the player appears on the other side, at least that was the idea.

My problem is that I have a line trace that fires when the player presses E and when it collides with a blueprints collision box it is supposed to fire an event where it teleports the player to the other side of the door using a scene components location as where the player ends up, but when e is pressed and the line trace hits the actor it goes through the collision box and hits the door instead, the blueprint does fire when it hits the door, but it fails to send the player to the set location. The doors have two collision boxes on both sides of the door as well, so of course one collision box allows the travel to the other side and the collision box allows travel back through the door. I haven’t found a way to get this working properly but if anybody has an idea how, It would be kindly appreciated if you told me cause a simple door blueprint has been driving me insane lmfao. I have my code attached to the post so you can see. if I need to post more code then I will gladly do it.

Thanks for helping if you do!

It looks ok, but what happens?

The blueprint fails to send the player to the location and in the message log it says: Blueprint Runtime Error: “Accessed none trying to read property player” which is odd as I have the Player controller Connected to the Variable type in the player variable. I know the event fires because I have added a sound that plays when the door opens and it plays when I press e on the door but it never sends my player character to the other side.

Ok the player variable need to point to the pawn :slight_smile: that’s the thing you’re moving

Ok now it works and send the player to the other side! Now I just need to figure out how to get it to where it can send the player to the other side of the door depending on which Collision volume the line trace hits. to rephrase what I said earlier, I have two collision boxes on either side of the door and I want the corresponding collision volume trigger when the line trace hits it so If Collision Box 1 gets hit it will send the player to Exit1 actors location and if the player turns around and looks at the door and press e then it will trigger Collision Box 2 and it will send the player to Exit2 actor location, allowing free travel between the doors. I know i’m asking for a lot right now, but do you happen to know anything I can do to allow this? Thanks if you do!

You don’t need to worry about the boxes, just always send the player 200 units forward:

](filedata/fetch?id=1821484&d=1602524807)

EDIT: I’ve already realised that wont work if the player decides to approach the door backwards, for instance.

I’d give up trying to hit the collision boxes and actually use them in the normal way:

So, make the door like this:

](filedata/fetch?id=1821486&d=1602525434)
The BP goes:

](filedata/fetch?id=1821487&d=1602525460)

ezgif.com-optimize.gif

He jumps a bit because of the height I placed the overlap volumes. You can either move them, or not take the Z from them…

I thank you for the suggestion but I want the player to choose which door to enter without it constantly teleporting them if they get too close. The horror game I’m making really relies on this and it would constantly be a pain if doors just straight up teleported you into a bad situation that the player is unprepared for or if they didn’t even want to go that way. is there any other way I could try this but with using the line trace and function I have? it doesn’t have to use the volumes btw.

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

Screenshot_7.jpg](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:

Tell me how it goes, because it’s too complicated to cover all bases. For instance is your project FP or TP?

I got the Door working! It now teleports the player to either side. My project is First person Btw. I have no real problems with this other then if the player is a little far away from the box and presses e it will cause them to teleport to the exit that they are at but it doesn’t happen if the player is fully in the collision box, I can figure out how to fix this on my own probably. Thank you so much for the help! it’s very appreciated!

You’re welcome. Do take a look at the interface stuff though, it will save you a lot of time in the long run :slight_smile: