I am trying to add a DING sound to play once an elevator stops moving. How could I go about this? Everything I tried makes it so that the DING sound occurs immediately after the elevator starts moving as opposed to once it stops.
I assume youāre using a timeline? Then you can use the āfinishedā pin.
No I have the movement set using begin/end overlap and just manually set the Z-value for each floor level.
Hey @ssophia_lee! Just like clockwork stated, one of the easiest ways to pull this off would be a simple timeline like so.
That said in your implementation of the elevator from the other port of yours, it may look a bit different. Youād have to make a way for it to detect itās at the proper location. I always advise against putting checks like that in your event tick as it will run indefinitely, but to tack an end state on quickly to your other implementation Iād do something along the lines of checking the position of the elevator and if itās at the correct location play the sound. Since youāve already got a nearly equals check in there, Iād just slap a Do Once node after that and have it only reset when a new button is hit.
Is there no other way to add the sound with what I have now? I am searching up timeline tutorials and it seems like it would be quite complicated to make an elevatorā¦
Oh thereās a myriad of ways to pull it off, some requiring more structural changes than others. I work from C++ usually so I have to transfer that knowledge to BPs so it takes me a bit. Iāll write up a little tester in a few!
Alright, so I think the simplest method from looking at your other script is probably this.
Basically taking your signal you already had to determine where to stop the elevator, making that do once, then taking the false condition as the reset for the do once. Let me know how that works for ya!
We donāt actually know what you have now, that would help
Hey @eblade! I recognized the username from another post the night before so I put 2 and 2 together, this is the original post about the elevator, you can see where I appended my code there at the end. UE4 Using Widgets as an input source?
ok, so, first off, I completely disagree with the way youāre doing this. But, without making major disruption to what youāre doing there, what I think you want to do is ā¦
You know when the elevator stops, because you set the direction to 0. Add a āRun Onceā node after that, connect your āPlay Soundā to that. Then wire the āFalseā on that branch before you set the direction to 0, to the āResetā pin on the Run Once.
So, when you stop, it hits the Run Once, which plays the sound. Then when it starts moving again, it resets the Run Once, so it will play again the next time it stops.
All of that said, I would approach this from like a completely different direction. Iāve not had the opportunity to create an elevator in Unreal 4 yet, but I think Iād try to make something that is much more easily reusable and easier to setup, by doing something likeā¦
Make an elevator Actor. Give it the usual static mesh component to represent the elevator itself. Add a Box component to it, that represents the area that it can move through, and then make a custom Component (call it like FloorMarkerComponent or some such), which you can add as many of as you need. Add one by default to it.
On BeginPlay, query for all of the FloorMarkerComponents that are owned by the Elevator, storing their location into an array ordered by their floor numbers. Then you just have an array that has all of the locations, and when you press whatever button corresponds to the floor, you can just set the destination by like Destination = FloorArray[FloorNumber].
Then when you want a new elevator, you just size the box component through the entire shaft it will travel, add a FloorMarkerComponent at each location you want it to stop, and youāre basically done.
As far as your movement goes, Timeline would be better to use to implement it, but is also a bit less straightforward to figure out. Itās a tool worth knowing, though, as itās built exactly for handling things like that.
That said, if you keep moving it around in Tick, it would be an optimization to turn off Ticking on the whole thing when you reach a destination, and then turn it back on when you start moving again. That would also prevent needing to use the Run Once before the Play Sound.
Good luck. If you try out any of my ideas, Iād love to know how they work, since like I said, Iāve never implemented an elevator in UE4+, so I wonder if my gut feel idea there would work / work well, or if it would just be a pain.
(i also just had a thought, if your floors are all standard heights, you wouldnāt even need the FloorMarkerComponent, you could just have a ānumber of floorsā and a āamount of space between floorsā, do some simple math, and youāre there)