Simple Line Trace doesn't work within trigger box
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: http://blueprintue.com/blueprint/k14j_oaw/
Door Blueprint: http://blueprintue.com/blueprint/p19de4vf/
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
asked May 02 '16 at 02:01 PM in Blueprint Scripting
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.
answered May 02 '16 at 02:29 PM
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 :)
answered May 02 '16 at 02:41 PM
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!
answered Jul 22 '17 at 11:43 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here