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

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.

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:

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:

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)

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.

Yes, that is correct.

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.

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.

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

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.

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

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Timelines/Examples/OpeningDoors/

Thank you very much!