x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

Thanks!

Product Version: UE 4.11
Tags:
more ▼

asked May 02 '16 at 02:01 PM in Blueprint Scripting

avatar image

CactusFantastico
75 7 19 22

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

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.

more ▼

answered May 02 '16 at 02:29 PM

avatar image

mikepurvis
2.4k 95 62 257

avatar image CactusFantastico May 02 '16 at 02:31 PM

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?

avatar image mikepurvis May 02 '16 at 04:45 PM

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.

avatar image CactusFantastico May 02 '16 at 04:59 PM

Right i think i solved it haha made a simple addition to the door blueprint like this: http://blueprintue.com/blueprint/5u0v1aoi/

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!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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

more ▼

answered May 02 '16 at 02:41 PM

avatar image

FrakiLoZ
6 1 2

avatar image CactusFantastico May 02 '16 at 03:03 PM

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.

avatar image DesertEagle_PWN May 02 '16 at 05:23 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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!

more ▼

answered Jul 22 '17 at 11:43 AM

avatar image

Inviter42
15 1 3 5

avatar image HeavyBullets Mar 13 '18 at 08:54 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question