Download

How to disable a trigger box?

EDIT: I solved the issue now. Check for solution-post further down!

---------Original question:-------------------------
Hello,

I’m currently trying to learn how to set up simple functions in blueprints and I’m really new to the software. I’ve done the basic tutorial now for making sliding doors in a trigger box, which UE-youtube page provides:

I’ve also done this other tutorial on how to make a door rotate 90+ degrees and open upon user input:

So far so good. I even managed to make the door that opens up 90 degree close itself after you leave the trigger box, as a direct result of combining the two tutorials (yay! Learning something).

Now I wish to expand on these tutorials a bit. I already made TWO sliding doors open in opposite directions from each other (i.e. doubling everything from the tutorial) and it all works great. I approach the door and the doors slide open and close after I leave the trigger box. But I want to be able to lock my house. So here’s a screenshot of my two trigger-boxes at the entrance door: The big box is for the doors, and the other, smaller one is for the key-lock I want to add:

I want to be able to walk up to the other key-lock-box and hit “E”. When doing that it should disable any inputs from the triggerbox that opens the doors. It should just make the game think that I’m not in it; if the doors are open when I lock the doors, they should close and not open again before I unlock the doors by pressing E again.

Here’s a screenshot for what I’ve set up so far regarding the input:

The lines above are just the standard commands that the tutorial teaches with some added sequence-branching to get the dual-doors working.
**
So is there any easy way to do this, or do I have to re-make the entire sliding doors to be able to insert the commands I want?**

I’d add a branch at the door open events and look at a bool for Locked. When you press E on the lock box, it toggles that bool. Then, the door will open if Locked is false and won’t if it’s true. You’ll still need to do some work to make the doors open or close right then if you’re already in the trigger and changed the Locked bool.

Something else to consider is moving the triggers (and really all of that functionality) inside your door blueprint so you can have direct access to them and not need to place them near each door in the level. You can then just drop doors anywhere you want and all the functionality is right there with it. A quick explanation of something similar I did for someone else is here:

Videos are still uploading but I setup the answer for you and show you how to create this by creating an actor instead of using the level blueprint to control the events.

Thank you!

Before I try your solution this is what I managed to do now:

I was just messing around and made the box the target of a “SetActor Enable Collision” which should be enabled when pressing E:

And to my surprise it worked: When pressing E the trigger box is disabled and the doors close and can’t be opened even if I stand inside the trigger box whilst pressing E. So yay. It worked.

Now I cannot open the doors. I can’t un-click the disable function (or at least I don’t know how to do that). Is there any way to do that?

P.s. I guess you want me to setup the slide-doors the same way as the other door is set up when in the other tutorial I linked?

So, what if you wanted to create another door with the same functionality? you would have to create another triggerbox to play another animation, to open two other doors you place in the level and so on. This is not a good way to do things. Check out the overview video at least to see what I am talking about. I can place the door anywhere and it works without ever having to set another blueprint.

No, I know it’s not good. But I’m just trying to learn the basic logic of the blueprints atm. Optimization comes later. :smiley: I just followed the tutorial, mate. But I’ll check out your video now, if it’s online. But the other door is done in blueprints as a separate object (cause that’s how that tutorial set it up. :smiley:

Now I’ve watched the vids. Thank you Sir for the videos.

These are the questions that came to my mind while watching this:

  1. How come you didn’t need to have all the “get actor location” stuff that the other tutorial sets up with with “event begin play” checking the door positions all the time?

  2. What’s the difference between “Set Actor Location” vs the “Set Relative Location” as you used?

  3. How did you get the program to understand the difference between “locked” and “unlocked” when you made the custom events that went into the false/true branches?

Then as a general feedback to the videos:

A) You haven’t linked the wrap-up video anywhere. :smiley: Just as a heads up

B) While you technically solved my problem, I still can’t have a specific trigger box that will lock/unlock the other door, which would be useful for making e.g. puzzles.

C) You could have mentioned that I did follow a tutorial when I did this in such a wrong way. :stuck_out_tongue:

But again, I really appreciate the fact that you took your time to record this just to help me! This really proves how great the UE4 community is

Before I make new door, could I use the “mess” I have and make that lock/unlock mechanism work?

I was wondering one thing here though… You mention that the issue here is that I cannot repeat this, no. That’s true. But the way you set it up, won’t every single door I copy be the same then? What if I need the same function, but on a different scale? E.g. Doors that are twice the width, but should move the same distance and so on. Will the scaling account for such stuff? Because if I change the blueprint for one door, it will change for all the other doors that uses the same blueprint, will it not? I’m asking cause I have no clue. BTW: I solved my make-shift issue with flip/flop (which you didn’t like, according to your videos). May I ask, why you don’t like flip/flop?

So I found the solution I was looking for; that is, to disable the trigger box that enables the doors to open in the first place.

So this is what I did:

  1. Set up a new trigger box (I called it “TriggerBox_Code lock”) and make it so that when I enter the trigger box, it will enable me to do key-inputs. That will look something like this:

part1.jpg

When entering the Code-lock trigger-box it will enable user input, and when leaving the box, user input is disabled.

  1. Make sure to create an actor reference for the door-opening trigger box (the one you want to disable).

  2. Find the E-key input-action and link that to a FlipFlop switch.

  3. From the door-opening actor make a “Set Actor Enable Collision”. Copy the “Set actor collision”.

  4. Link FlipFlop A to one of the function-boxes, and FlipFlop B to the other. Link “Is A” to both of the boxes. The final result should look like this:

Hope this may help anyone who wants to expand a bit on the basic tutorial given by Unreal Engine Devs: Intro to Level Creation: Overview | 01 | v4.7 Tutorial Series | Unreal Engine - YouTube

Sources from where I took inspiration for this solution:

https://answers.unrealengine.com/questions/93921/how-to-use-multiple-inputactions-for-1-key-press.html

**NOTE! I fully agree with James94Hodges that this solution is not the most elegant and absolutely not the most efficient. Especially if you need multiple doors with the same functionality. But for new beginners, like me, who just wants to start grasping the logic of how blueprints works, this is a great little solution. AND it enables you to lock the door from far away too.

Please check out James94Hodges video on how to set up these kind of doors in the proper manner which can be used for more advanced applications! Videos can be found here:**
Intro: UE4 Questions Answered: Lockable Door Overview - YouTube
Part 1: UE4 Questions Answered: Lockable Door - YouTube
Part 2: UE4 Questions Answered: LockableDoorWrapUp - YouTube

This is one of the great things about Blueprints. Dig around for more tutorials to learn how to make a single door blueprint work for tons of different types of scenarios. You can plop down a BP in your level, click some check boxes, slide some sliders, choose from some dropdowns and have a ton of different looks and functionality from the same thing. You just need to define what you want and then set it up. It takes time to see all the possibilities, but keep going through the tutorials and you’ll hit that Eureka moment and suddenly you’ll see a ton of new stuff you can make happen really easy.

I understand that the point of the tutorial was to teach some basic functionality. And I said wrong, but really, when it is all said and done, if it works, it is never wrong…just a different way.

1 & 2) An actor placed in a world is at location x. The components inside of that actor can be placed at a relative distance to itself. And if you attach a component to a component inside an actor, when you change the relative location down the chain, it will move from its parent component. This is done by setting the relative location. Therefor, when you change a components location relative to its parent, when you move it to 10, 10, 10 from 0, 0, 0, anywhere in the world it move only 10, 10, 10. If you were to set the location to world space it world move every door to the world location of 10, 10, 10 no matter how far away it is.

  1. I think you figured this out already.

Thanks for the feedback.

Addressing comment B) "While you technically solved my problem, I still can’t have a specific trigger box that will lock/unlock the other door, which would be useful for making e.g. puzzles. "

I’ll show you a good way to make a door with a separate lock/trigger system that is super easy to place in the world and set up. Video coming later today.

Thanks for the props up top. I really appreciate it. As i said earlier, here is the link to having a separate switch for a puzzle game. UE4 Questions Answered: Lockable Door With Separate Switch - YouTube (possibly still uploading) I kind of went overboard on making a simple switch but if you want a puzzle game the final result is pretty good.