Simple Line Trace doesn't work within trigger box

Hey Guys!

Basically what I want to do is make it so you have to be looking at a door as well as within a short distance to it when you press E for the door to open. I have it set up so when the player presses E they do a simple line trace that looks for the door and if it misses, it changes a parameter on the door to false and when it hits, its true. This is coupled with the door having a trigger box which sets another value to true if you overlap and false if you leave. I set it up so that only if both of these events are true should the door open.

Now here’s where things are going wrong haha

The line cast seems to be working, appropriately setting the variable on and off, if I look at the door and press E, i can walk up and open it, if i press E away from it and go up to the door, it wont open but here is where it gets weird. Once I am inside that trigger box, if the cast has set the variable as true, i can continue to cast and turn it on and off but once its set to false by either before or after inside the trigger box, i can no longer cast until i leave the trigger box again.

Here are the blueprints for both the door and the simple cast in the player controller:

Player Line Trace:

Door Blueprint:

I thought it would be better to link more directly to the blueprints because its hard to see in screenshots haha
I am hoping you guys can help me out as I am at a lost for what it would be haha


There could be a number of things going on.

My suggestion is to get rid of the line trace that’s setting a variable. You only care if it’s facing, which isn’t a line trace, and you only care if it’s facing when the trigger is hit which is an event.

So, on the trigger event check the facing of the actor that triggered the event. It’s not a line trace. Get the Actor forward vector and get a line from the Actor location to the door location. Get the Dot product of those two vectors.

The sign of the Dot product will tell you if it is facing or not. Negative is facing.

Ah nice, I forgot to mention I was welcome to finding other ways to achieve this haha thanks.

Yeah I’ll have to check to see how I would do that, I imagine it wont matter what rotation the door is at, as long as you are facing it?

Hi, i think we have a case of unnecessary blueprint complexity here ^^

The trigger to check the distance to the door is useless since you can set the range of your linetrace to be the distance you want for the activation, just have to change the float you are multiplying your forward vector with.

This should maybe work or at least simplify the process of correcting your problem :slight_smile:

That is a very good point xD I will prob move away from using line trace as the other guy said but you are super right haha silly me.

Correct, well, if that’s your design. You could compare a vector coming perpendicular off the door frame DotProduct with the forward vector of the actor that triggered the event.

Right i think i solved it haha made a simple addition to the door blueprint like this:

and it seems to work now haha It actually didn’t originally but that seemed to be because i had two key press actions going at the same time, if i instead linked the end of this new blueprint addition into the start of the door opening stuff, it works fine. This has made me realised the problem all along was prob because i had both blueprints working off pressing “e” which must have conflicted in this weird way. If i potentially want to go back to using line trace, it would prob work if i make it a event dispatch triggering the door opening instead of both them running from “e”

Also luckily the doors in my game are one way and are removed and another spawned in its place or getting back through the door prob wouldn’t work this way haha

Thanks a lot!

This should work and is the solution I would have come to; however, mikepurvis’s solution is more elegant and most likely more performant – albeit a bit less intuitive.

I believe you already solved the problem, but may be it’ll save some time to the others.

It’s not like line trace doesn’t work within the trigger box. It doesn’t work within itself. You need to uncheck the “Ignore Self” checkbox in the LineTrace setting in order for it to work.

Have a good day!

Gotta say… after 40 minutes banging my head… this was the issue for me…
Have an upvote, and a kiss from afar