# Setting Up Door Open/Close In C++

**URL:** <https://forums.unrealengine.com/t/setting-up-door-open-close-in-c/367265>\
**Category:** Blueprint\
**Tags:** timeline, unreal-engine, Scripting, CPP, Blueprint, question\
**Created:** [August 16, 2016, 3:04am UTC](https://forums.unrealengine.com/t/setting-up-door-open-close-in-c/367265 "2016-08-16T03:04:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![joelComberiati](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@joelComberiati](https://forums.unrealengine.com/u/joelComberiati)\
**Post date:** [August 16, 2016, 3:04am UTC](https://forums.unrealengine.com/t/setting-up-door-open-close-in-c/367265/1 "2016-08-16T03:04:35Z")

</div>

Hello,  
I am trying to simply open and close a door. I have a few ideas of possible methods, but I am not sure which one, if any, are the best. Now what I do is create a blueprint on the AInteractableDoor class, and then place it in my world. Now technically this would not only be used for doors, it would also be used for windows that can possibly slide upwards, or be the classic house style door that opens in/out, or it could even be a sliding door that goes to the right or the left. No the easiest way I can think of to do this, is have an animation that I can set in blueprints where I can just hit play when I want to open it. I have seen a timeline being talked about for the most part. But since I would have to work with blueprints a little more than I would like (cant do it in c++ because I cant change it in the blueprint, unless there is a way to do this I am unaware of, highly likely). The other option is create a position/rotation that I would like the door to get to, and get there through the tick function. These are just the things I could think of, if there is a better way, Id be glad to hear it.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_86746194](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_86746194](https://forums.unrealengine.com/u/anonymous_user_86746194)\
**Post date:** [August 16, 2016, 3:54am UTC](https://forums.unrealengine.com/t/setting-up-door-open-close-in-c/367265/2 "2016-08-16T03:54:00Z")

</div>

Timeline and animations are the way to go. If your trigger condition is met (pressed interact key, walked into a trigger box, whatever), trigger an event in your blueprints that starts the Timeline. The output float value of the timeline determines how far in the animation it needs to be. You would play the timeline in reverse to close the object.

By the way, this type of behavior is what blueprints are really made for outside of prototyping. The trigger is fine in C++, but the events caused by the trigger in regards to cosmetics should be done in blueprint.

---

<div class="post-metadata">

**Author:** ![joelComberiati](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@joelComberiati](https://forums.unrealengine.com/u/joelComberiati)\
**Post date:** [August 16, 2016, 5:12am UTC](https://forums.unrealengine.com/t/setting-up-door-open-close-in-c/367265/3 "2016-08-16T05:12:47Z")

</div>

Okay, I have not done much with animation, I will give it a try

---

<div class="post-metadata">

**Author:** ![joelComberiati](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@joelComberiati](https://forums.unrealengine.com/u/joelComberiati)\
**Post date:** [August 16, 2016, 5:25am UTC](https://forums.unrealengine.com/t/setting-up-door-open-close-in-c/367265/4 "2016-08-16T05:25:37Z")

</div>

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

So After looking through this, it seems pretty simple. I can pretty easily get this to work, but it looks almost identical to what I would do in c++. Is doing it this way more efficient in some way? Or is it simply due to ease?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_86746194](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_86746194](https://forums.unrealengine.com/u/anonymous_user_86746194)\
**Post date:** [August 16, 2016, 5:32am UTC](https://forums.unrealengine.com/t/setting-up-door-open-close-in-c/367265/5 "2016-08-16T05:32:15Z")

</div>

Ease is relative. I find blueprints harder to use than C++. The tutorial there works fine as well with the only difference being they manually set the actual location of the mesh instead of using an animation. There really is no difference whether you do it in blueprints or C++ as this kind of thing wouldn’t really benefit from C++'s speed benefits.

---

<div class="post-metadata">

**Author:** ![joelComberiati](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@joelComberiati](https://forums.unrealengine.com/u/joelComberiati)\
**Post date:** [August 16, 2016, 6:34am UTC](https://forums.unrealengine.com/t/setting-up-door-open-close-in-c/367265/6 "2016-08-16T06:34:39Z")

</div>

Okay, Good to know, you have been very helpful

---

<div class="post-metadata">

**Author:** ![LuisAlaguna](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/luisalaguna/32/570408_2.png) [@LuisAlaguna](https://forums.unrealengine.com/u/LuisAlaguna)\
**Post date:** [March 31, 2020, 1:50pm UTC](https://forums.unrealengine.com/t/setting-up-door-open-close-in-c/367265/7 "2020-03-31T13:50:49Z")

</div>

You can also follow this tutorial: [https://unrealcpp.com/open-door-with-timeline/](https://unrealcpp.com/open-door-with-timeline/)
