# Place blocks in specific places to open a door?

**URL:** <https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373>\
**Category:** Community & Industry Discussion\
**Tags:** keys, unreal-engine, door, question\
**Created:** [March 9, 2017, 2:14am UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373 "2017-03-09T02:14:05Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheForeverFeared](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheForeverFeared](https://forums.unrealengine.com/u/TheForeverFeared)\
**Post date:** [March 9, 2017, 2:14am UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/1 "2017-03-09T02:14:05Z")

</div>

I’m trying to make it so when numbered blocks are placed in their correct spots, 1 door will open. I have made the blueprint for moving the blocks themselves but how and what is the easiest way to make this happen? Pictures help me a lot. Thanks!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bd3dfdf6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bd3dfdf6](https://forums.unrealengine.com/u/anonymous_user_bd3dfdf6)\
**Post date:** [March 9, 2017, 8:35am UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/2 "2017-03-09T08:35:09Z")

</div>

Write down the locations of where the blocks have to be, then open level blueprint, make references to all blocks (select block, go to level blueprint) , make event tick, branch, to branch add if the locations of those blocks are equal to where they need to be and if yes, open door.

---

<div class="post-metadata">

**Author:** ![Mosel3y](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mosel3y](https://forums.unrealengine.com/u/Mosel3y)\
**Post date:** [March 9, 2017, 12:13pm UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/3 "2017-03-09T12:13:14Z")

</div>

Here is another method which doesn’t rely on hardcoded locations, and would be more adaptable and reusable.  
Also it doesn’t use tick which isn’t necessary for this. It will take a bit longer to set up, but if you ever need to re-use this system it will be a lot easier.

**1. Create a blueprint class for blocks, BP\_Block**

- Add an int variable, Block Number. Click the eye symbol to make it public.

In my example I have just a Cube mesh with physics enabled that can be picked up and moved around, this will probably be different depending on how you are doing yours.

**2. Create a Blueprint class which be placed in your scene and represents a location that a block needs to be placed, BP\_BlockPosition.**

- Add int variable BlockPositionNumber. Click the eye symbol to make it public.

- Add two bools, Occupied, and CorrectBlockPlaced

And a Box Collision component, this will sense when a box is placed in it. Again, this might differ from how you are doing it.

**3. Create a new BP class called, BP\_BlockController.**

This will keep track of how many blocks need to be placed, and how many have been placed correctly etc.  
With the way this is set up, you will be able to have as many block puzzles in your level as you want.

- Add variable array of BP\_BlockPosition. Click the eye symbol to make it public.
- Add int variable, NumberOfBlocks
- Add int variable, NumberOfOccupiedBlocks
- Add int variable, CorrectlyOccupiedBlocks

Add a custom event, BlockStateChanged, and the below nodes:

 ![129263-bp_blockcontroller.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/e/a/aea431fd51818da3395ce390a5b4da0a5db0f4cf.jpeg)

**4. Go back to BP\_BlockPosition**

Create BeginOverlap and EndOverlap events for the box collision.  
Add variable, BP\_BlockController.  
Also on beginplay make it get a reference to the block controller. (If you want to have multiple block puzzles in your level, instead make this variable public, and don’t use get all actors of class, instead set the reference to the right controller directly in your level. There’s no reason to do that if there is only ever one puzzle though)  
Set up the below:

 ![129523-bpp.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/0/f/60f48c45c1b53a46ec3e36ae7aa8bdec3459edcd.png)

The == node on the GetClass should be checking for your BP\_Block class

**5. Add it all to you level.**  
So, however many blocks you want, and a matching nuimber of BP\_BlockPositions.  
Add a BP\_BlockController too.  
In its details, add elements to BlockPositions, and choose the block positions from the scene.

 ![129265-setup.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/f/4/2f4c64920cad988f70f73ab8c7723088b3f44d89.jpeg)

Now set the ints on the Blocks and the BlockPositions, it should match so that there is a corresponding BlockPosition for each Block.  
So if you have a BP\_Block with BlockNumber 56, set one of the BP\_BlockPositions to also have BlockNumber 56.

---

<div class="post-metadata">

**Author:** ![TheForeverFeared](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheForeverFeared](https://forums.unrealengine.com/u/TheForeverFeared)\
**Post date:** [March 9, 2017, 7:59pm UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/4 "2017-03-09T19:59:25Z")

</div>

Any Idea as to why it says the target is invalid?

 ![129324-capture.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/1/c/01c94c11e5181ba98697e2469f5d342ce08d9395.jpeg)

---

<div class="post-metadata">

**Author:** ![Mosel3y](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mosel3y](https://forums.unrealengine.com/u/Mosel3y)\
**Post date:** [March 9, 2017, 8:20pm UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/5 "2017-03-09T20:20:26Z")

</div>

Try Right clicking on that Cast node, and choose “convert to pure cast”

---

<div class="post-metadata">

**Author:** ![TheForeverFeared](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheForeverFeared](https://forums.unrealengine.com/u/TheForeverFeared)\
**Post date:** [March 10, 2017, 2:30am UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/6 "2017-03-10T02:30:59Z")

</div>

It worked, thanks a lot! Do you know how I would go about having a door open when the blocks are placed in the correct places?

---

<div class="post-metadata">

**Author:** ![Mosel3y](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mosel3y](https://forums.unrealengine.com/u/Mosel3y)\
**Post date:** [March 10, 2017, 10:21am UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/7 "2017-03-10T10:21:24Z")

</div>

Great 🙂 So, you could create a BP\_Door class, give it a custom event that will open it. Add a BP\_Door variable in BP\_BlockController, click the eye symbol to make it public. Then place a door in your level, and click the BP\_BlockController, set the Door variable to point to your Door.

Where the AllPlaced correct print string is in your BP\_BlockController, get your door reference, drag off from it and call your Open Door event.

Doing the open door bit would be a separate question but there’s a lot of infoirmation on that online already too. Hopefully this will get you started.

---

<div class="post-metadata">

**Author:** ![TheForeverFeared](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheForeverFeared](https://forums.unrealengine.com/u/TheForeverFeared)\
**Post date:** [March 10, 2017, 10:07pm UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/8 "2017-03-10T22:07:56Z")

</div>

Do you have an image of what that might look like? Sorry, I’m new to unreal.

---

<div class="post-metadata">

**Author:** ![TheForeverFeared](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheForeverFeared](https://forums.unrealengine.com/u/TheForeverFeared)\
**Post date:** [March 10, 2017, 10:31pm UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/9 "2017-03-10T22:31:08Z")

</div>

Also the only string working is not all placed

---

<div class="post-metadata">

**Author:** ![Mosel3y](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mosel3y](https://forums.unrealengine.com/u/Mosel3y)\
**Post date:** [March 10, 2017, 10:35pm UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/10 "2017-03-10T22:35:34Z")

</div>

If that’s the only one working you must have set something up wrong, can you send some screenshots of your blueprint?

---

<div class="post-metadata">

**Author:** ![TheForeverFeared](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheForeverFeared](https://forums.unrealengine.com/u/TheForeverFeared)\
**Post date:** [March 10, 2017, 11:02pm UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/11 "2017-03-10T23:02:16Z")

</div>

Here are my blueprints. I made sure that each block had a matching position number as well. Yet when I move the blocks to all the right places, the string never pops up.

---

<div class="post-metadata">

**Author:** ![Mosel3y](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mosel3y](https://forums.unrealengine.com/u/Mosel3y)\
**Post date:** [March 10, 2017, 11:06pm UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/12 "2017-03-10T23:06:32Z")

</div>

In your scene you have set the Block Number int on the boxes, and also on the BoxPoisitons?

---

<div class="post-metadata">

**Author:** ![TheForeverFeared](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheForeverFeared](https://forums.unrealengine.com/u/TheForeverFeared)\
**Post date:** [March 10, 2017, 11:23pm UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/13 "2017-03-10T23:23:03Z")

</div>

yes. example: the order for the blocks is 39145. so on position 1 i set the int to 3 and the block 1 int to 3. on position 2 i set the int to 9 and the block to 9, ect.

---

<div class="post-metadata">

**Author:** ![Mosel3y](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mosel3y](https://forums.unrealengine.com/u/Mosel3y)\
**Post date:** [March 10, 2017, 11:27pm UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/14 "2017-03-10T23:27:32Z")

</div>

But you also have to set the int in the block itself, so in your case you will need 5 blocks, one with the Block Number int set to 3, one set to 9, one set to 1, etc.

If you’ve already done that then I can’t see what could be wrong, if you want to upload the project somewhere and send a link on the forums PM I can check it.

 ![129500-bl.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/c/d/3cd2d56a798673a1fa51353972848e8d3a5d0788.png)

---

<div class="post-metadata">

**Author:** ![TheForeverFeared](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheForeverFeared](https://forums.unrealengine.com/u/TheForeverFeared)\
**Post date:** [March 11, 2017, 12:52am UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/15 "2017-03-11T00:52:13Z")

</div>

> **[Dropbox - File Deleted](https://www.dropbox.com/s/aw2p0llb6tovydm/Puzzle.zip?dl=0)**
>
> Dropbox is a free service that lets you bring your photos, docs, and videos anywhere and share them easily. Never email yourself a file again!

---

<div class="post-metadata">

**Author:** ![Mosel3y](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mosel3y](https://forums.unrealengine.com/u/Mosel3y)\
**Post date:** [March 11, 2017, 1:25am UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/16 "2017-03-11T01:25:50Z")

</div>

So it was a mistake with my setup, sorry about that! It could “lose count” if two blocks were in one location and then one was removed. The below fixes it:

Store the current block when it’s overlapped, the only call the state changed function if it’s the same block being removed.

 ![129522-bpp.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/1/d/61de33c78ae5f5969037a9a085568d975f12dfa0.png)

][1]

---

<div class="post-metadata">

**Author:** ![TheForeverFeared](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheForeverFeared](https://forums.unrealengine.com/u/TheForeverFeared)\
**Post date:** [March 12, 2017, 5:17am UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/17 "2017-03-12T05:17:28Z")

</div>

Would the current block variable be type bp block?

---

<div class="post-metadata">

**Author:** ![Mosel3y](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mosel3y](https://forums.unrealengine.com/u/Mosel3y)\
**Post date:** [March 12, 2017, 5:37am UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/18 "2017-03-12T05:37:46Z")

</div>

It can be actor. reference. Drag off from other acor and promote it to variable

---

<div class="post-metadata">

**Author:** ![TheForeverFeared](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheForeverFeared](https://forums.unrealengine.com/u/TheForeverFeared)\
**Post date:** [March 12, 2017, 11:26pm UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/19 "2017-03-12T23:26:56Z")

</div>

Sweet now it works, thank you so much? now how do I implement the door to work?

---

<div class="post-metadata">

**Author:** ![Mosel3y](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mosel3y](https://forums.unrealengine.com/u/Mosel3y)\
**Post date:** [March 12, 2017, 11:41pm UTC](https://forums.unrealengine.com/t/place-blocks-in-specific-places-to-open-a-door/387373/20 "2017-03-12T23:41:39Z")

</div>

Great. In BP\_BlockController, add a new variable of type BP\_Door. Make that variable editable by clicking the eye symbol.

Where the All Placed Correctly print string is, replace that with a call to your DoorOpen event in BP\_Door:

 ![129784-door.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/6/6/8666a30be88baf47633a5c42b0199f40a19d9928.png)

Then in your level, set the value of Door, to be the BP\_Door placed in your scene.

The door opening setup you have in BP\_Door needs to be changed a bit. Open your timeline and change the graph so that the second point’s value is 1. At the moment it’s 100. Then do this:

 ![129785-doorgraph.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/0/5/405f6e18a985c3bab6c1a7f716e297a62bdf5765.png)
