# 'SetPlayRate' being called before 'Play' (Level Sequence)

**URL:** <https://forums.unrealengine.com/t/setplayrate-being-called-before-play-level-sequence/368702>\
**Category:** Character & Animation\
**Tags:** unreal-engine, UE4, Blueprint, question\
**Created:** [August 30, 2016, 1:39am UTC](https://forums.unrealengine.com/t/setplayrate-being-called-before-play-level-sequence/368702 "2016-08-30T01:39:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_13041b711](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_13041b711](https://forums.unrealengine.com/u/anonymous_user_13041b711)\
**Post date:** [August 30, 2016, 1:39am UTC](https://forums.unrealengine.com/t/setplayrate-being-called-before-play-level-sequence/368702/1 "2016-08-30T01:39:43Z")

</div>

I’m trying to create an automated door script by figuring out if a player is looking at a door, and then playing the associated Level Sequence.

The door detection works perfectly, getting the actual level sequence works perfectly, however _playing_ the level sequence does not. I walk up to the door and hit E, and nothing happens. I hit E again, and the door begins working perfectly. It toggles its ‘opened’ and ‘closed’ states and works fine.

I am not using booleans because that would mean having to set up a boolean for _every_ door on the map (at least to my knowledge it would) to check if opened or closed. Instead, I use GetPlayRate and if it’s set to -1, then that means it is _pending close_ - it plays at a rate of -1 to close, then I set it to 1 to say it’s _pending open_, and then when played it sets back to -1, and yadda yadda yadda.

That works perfectly, but I have to double tap E to get it to work the first time, and then it works flawless every time I press E after that.

[](https://i.imgur.com/9tCYevo.png)

As seen above, I check if the play rate is above 0 (I have tried with “== 1”) and if so, it plays it (so it opens the door) and then says ‘SETTING TO -1’ and sets to -1. However, what actually happens is, it sees that it is greater than 0, but it _doesn’t_ play the animation, and it sets the play rate to -1. When I press E again, it opens the door and then says ‘setting play rate to 1’. Opening my door is when the play rate is at 1, which means the play rate is set _before_ it plays, yet I have set it up in such a way that this shouldn’t be happening:

[](https://i.imgur.com/fA7qnb1.png)

When I now press E, it prints ‘setting to 1’ and then opens the door. It prints ‘setting to -1’ and closes the door, the opposite of what I intended. It’s as if the play rate is being set before it’s playing, which would explain why the door ‘closes’ when it’s set to -1 (in reality it doesn’t even play the closing animation), and then opens at 1 again.

I tried playing it twice in succession but this did not help. I have tried swapping it around so that it works the way the ‘bug’ works, but if I do it this way, the door gets stuck open and doesn’t close, even though the play rate is being set to 1 and -1 respectively. The sequence itself is just a door rotating through 90 degrees.

Is there anything wrong with my blueprint setup? I for the life of me cannot figure it out and I’m pulling my hair out. I don’t want to use trigger boxes because I need to be able to detect when someone is looking at a door, or even a part of a door (like a lock), not just in a trigger box.

Level blueprint:

[](https://i.imgur.com/APttG2p.png)

The door animation is attached to the door and then I use _GetAttachedActors_ to find the animation of the door that is currently being looked at. I find that door by using a LineTrace, and then doing a for loop to check if any of the attached actors are of the class ‘Level Sequence Actor’. That part works flawlessly though.

EDIT: I also sometimes have to _really_ spam the E button to get it to work. Like, I have to hit it in rapid succession about 8 times before it opens, and again, it opens the ‘wrong way’ (open then set to 1, close then set to -1)

---

<div class="post-metadata">

**Author:** ![VictorBurgos](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/victorburgos/32/1008648_2.png) [@VictorBurgos](https://forums.unrealengine.com/u/VictorBurgos)\
**Post date:** [August 30, 2016, 4:23am UTC](https://forums.unrealengine.com/t/setplayrate-being-called-before-play-level-sequence/368702/2 "2016-08-30T04:23:58Z")

</div>

I just want to confirm, you just want to be able to OPEN and CLOSE a door correct? Depending on the which door the player is looking at.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_13041b711](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_13041b711](https://forums.unrealengine.com/u/anonymous_user_13041b711)\
**Post date:** [August 30, 2016, 4:24am UTC](https://forums.unrealengine.com/t/setplayrate-being-called-before-play-level-sequence/368702/3 "2016-08-30T04:24:43Z")

</div>

Yes, that is correct.

---

<div class="post-metadata">

**Author:** ![VictorBurgos](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/victorburgos/32/1008648_2.png) [@VictorBurgos](https://forums.unrealengine.com/u/VictorBurgos)\
**Post date:** [August 30, 2016, 5:45am UTC](https://forums.unrealengine.com/t/setplayrate-being-called-before-play-level-sequence/368702/4 "2016-08-30T05:45:15Z")

</div>

Line Trace it from Player World Location to Forward Vector. OutHit result, make sure to cast to the door. Then have it open with a button press or however you want.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_13041b711](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_13041b711](https://forums.unrealengine.com/u/anonymous_user_13041b711)\
**Post date:** [August 30, 2016, 2:40pm UTC](https://forums.unrealengine.com/t/setplayrate-being-called-before-play-level-sequence/368702/5 "2016-08-30T14:40:15Z")

</div>

I’ve done that and I can get the door fine and everything attached to it. The only issue is, the level sequence doesn’t play the first time I press E. It only plays the second time, and it plays with rate ‘1’ _before_ setting the rate to ‘1’, and I cannot get the sequence to play on the first time. I have to press E to ‘initialise it’, and then after that it plays seemingly in the wrong direction.

---

<div class="post-metadata">

**Author:** ![VictorBurgos](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/victorburgos/32/1008648_2.png) [@VictorBurgos](https://forums.unrealengine.com/u/VictorBurgos)\
**Post date:** [August 30, 2016, 5:03pm UTC](https://forums.unrealengine.com/t/setplayrate-being-called-before-play-level-sequence/368702/6 "2016-08-30T17:03:14Z")

</div>

It was a bit late when I replied. But, why are you using “level sequence” and not a Timeline to open the doors?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_13041b711](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_13041b711](https://forums.unrealengine.com/u/anonymous_user_13041b711)\
**Post date:** [August 30, 2016, 5:05pm UTC](https://forums.unrealengine.com/t/setplayrate-being-called-before-play-level-sequence/368702/7 "2016-08-30T17:05:40Z")

</div>

I don’t know anything about timelines and since I used Matinee before, I thought Sequencer would fulfil the same role. I’ll look up timelines and see if they can fix my problem.

---

<div class="post-metadata">

**Author:** ![VictorBurgos](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/victorburgos/32/1008648_2.png) [@VictorBurgos](https://forums.unrealengine.com/u/VictorBurgos)\
**Post date:** [August 30, 2016, 5:14pm UTC](https://forums.unrealengine.com/t/setplayrate-being-called-before-play-level-sequence/368702/8 "2016-08-30T17:14:28Z")

</div>

Timelines will be much easier for you. They also have the added benefit of having a “REVERSE” execution.

---

<div class="post-metadata">

**Author:** ![VictorBurgos](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/victorburgos/32/1008648_2.png) [@VictorBurgos](https://forums.unrealengine.com/u/VictorBurgos)\
**Post date:** [August 30, 2016, 5:15pm UTC](https://forums.unrealengine.com/t/setplayrate-being-called-before-play-level-sequence/368702/9 "2016-08-30T17:15:26Z")

</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 — https://unrealcommunity.wiki/! You will be able to find content from...

[https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Timelines/Examples/OpeningDoors/](https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Timelines/Examples/OpeningDoors/)

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/d/6/9d65fc82352109a201b00e921942dfdb1dcef03c.jpeg "Unreal Engine 4 Tutorial - Open Close Door with Triggers and Matinee") ](https://www.youtube.com/watch?v=dUPCTfCc2kM)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_13041b711](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_13041b711](https://forums.unrealengine.com/u/anonymous_user_13041b711)\
**Post date:** [August 30, 2016, 5:15pm UTC](https://forums.unrealengine.com/t/setplayrate-being-called-before-play-level-sequence/368702/10 "2016-08-30T17:15:28Z")

</div>

Thank you very much!
