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:
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
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.
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
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