Multi-floor elevator problem using variable-controlled timeline

This is my first time attempting to assemble a multi-floor elevator from scratch, and I feel like I’m very close to getting it to work except for an issue I’m having with controlling the timeline that powers it.

My current setup is pretty simple: I’ve set up colliders for each floor that generate the current floor number on overlap. I then multiply that number by 250, which is the height of my floors. This allows the elevator to go up to exactly the floor i want when pressing any of the button on my control panel widget, which i have set up to send specific floor numbers to a variable that i use to select the appropriate floor for the elevator to go to.

The problem is that once the elevator reaches the floor, the timeline seems to “burn out”, causing the elevator to simply “snap” to the selected floor, instead of travelling smoothly to it, which suggests that the timeline is stuck to its last frame.

I have thus created a Boolean variable ELEVATOR_UP which compares the current floor number with the selected floor number. When returning true, a branch directs the timeline to move forward, conversely when returning false, it plays in reverse. Apparently, this does not work and I’m not sure what I’m doing wrong here.

Any suggestion is appreciated, as I’ve been running in circles on this for a few days now… :slight_smile:






Hey @ExopackVFX!

Looking at your Elevator Moves function, I’m seeing:

Timeline Float Value * New Floor = Set New Location Z.

If you move to the 6th floor and then to 2nd… The timeline does not reset its time after use once, so after that it uses the old value, meaning the end if that ran the timeline to the end. For that you need PlayFromStart, not Play, and never use reverse.

Really what we need to see here is your inner workings of your timeline. I could just suggest using Reverse instead of Reverse from End but without knowing your timeline I can’t say that.

Get that for us and I bet we can figure it out, if not redo the system quickly. :slight_smile:

Thanks!

The timeline is a float, runs for 5 seconds, and only has two keyframes, the first is 0.0 and the last is 1.0. I’ve created an opposite one in this reworking of my blueprint.

When i try to play the timeline from the start, it snaps to the destination floor, and then moves back to frame zero, which is the opposite of what i want, so basically it’s still doing the same thing…


Okay, you don’t need to use two timelines.

If it needs to go up, use play from start. Then it will start from (Time|value) 0|0 each time, and go to 1|1. Then just have it repeat for each floor until the one you need is reached.

If it needs to go down, it becomes complicated however, as it depends on how it is set up. If you use reverse from end, then it will start from 1|1 each time and go to 0|0. However if it is going from “Current floor” to “New floor”, even if it’s going DOWN, you will change NOTHING and only use the play from start.

I also noticed that the “ELEVATOR MOVE” function no longer has an input float in the second image- not sure if that matters.

Hope this helps!

Yes that makes sense, good catch on the input float! I changed the input slightly to internally call the variable “DESTINATION” set along the update pin of each of the two timelines, to clean the spaghetti a little :slight_smile:

So my question at this point i guess it’s more about the best way to setup my blueprint to make the elevator travel down.

I tried a number of things, including a for loop where i make the timeline repeat itself by the number of floors, but that either does nothing or causes infinite loop crashes, and if i just play in reverse from the end it still just snap instantly.

What would you suggest as an alternative approach for what I’m trying to accomplish?

Could you show the new code?

If you put a ForLoop in tick, yeah you’ll get a crash. It seems like re-running the code on each floor is good.

Alternatively, you could get rid of the timeline entirely. You could do an Interp node with a set speed to go from point A to point B. In fact I’m thinking that’s the better way to go about this. You won’t need to track if it’s up or down, just set “Starting position” as a variable (don’t constantly update it) and have the goal Z set. Then use a “Set Actor Location” node from that. Then you can adjust the speed at the bottom of the node.

I’m liking the Interp node suggestion! Timelines appear to be a little too unpredictable, so if there is an alternative method, i’m definitely open to experimenting!

Would you be able to provide a little example of how to implement an Interp node? I don’t think I’ve used it as much. Sounds like i can still re-use much of the data i’ve already generated with this solution, right? Like the collision boxes to generate floor numbers, and maybe the boolean to keep track of the position of the elevator in relation to the next selected floor?

This is what’s inside the function that moves the elevator after the timeline:

You probably will specifically need this.

You will probably not need this! We can use quick math to avoid needing it, unless you need it elsewhere.

I threw something together- Strangely it is acting up unless the floor number variables are exposed, so if it goes fast while going down, expose them. We’re going to use this “Run Elevator” custom event and a timeline, instead of tick, and a LERP instead of an interp. This is on the actual elevator itself, and can be placed anywhere. Also it is non-USA style, so ground floor is floor 0 and floor 1 is the first upper floor.

You can try to work this into what you have, it’s tested and working. For this you just have to Set “Desired Floor Number” and then call “RunElevator”.

I hope this gets you all sorted out! :slight_smile: :slight_smile:

This looks awesome thanks! I’ll definitely delve into it and post my results.
I like to start my floors from 0 as well, in case i need to sync my data with arrays, like the ones i created to sync the UMG buttons to the actual buttons of the control panel.

Will let you know how it turns out!

You are an absolute rockstar!
I wasn’t even thinking of using the timeline as an alpha to lerp into the set transform for the elevator!

I literally just added two nodes, gutted my original timelines setup, and now this thing works like a charm, with the added bonus that now I don’t have to have an added check to stop players from triggering the control panel while the elevator is in motion, which is something i meant to work in next.

Thank you so much!!



It looks great! If you want to have it go the same speed regardless of the floor goal, you’ll have to use the increment/decrement floor re-run method I posted, so if you wanted to do that and have any questions, let me know!

Excellent stuff @Mind-Brain
I know this is solved, but I wanted to offer another solution.

Bonus: Multiplayer ready

Event Graph

Construction

OnRep Function for New Floor integer
Majority of the Logic is here

Floor TMap (holds the Relative Z Axis)

There’s also a SPEED (Float). This controls how long it takes to do a “SINGLE” floor transition. The Onrep function handles the timeline play rate speed based on the number of floors being transitioned.


1 Like

Thanks!

My current project is quite extensive, and I’m sure I’ll need more help with underground elevators and platforms, so I’m definitely interested in exploring different solutions to suit different methods of travel across different heights.

This one in particular has been requiring more thought, because I have planned it to have “secret hatches” that can be opened while the elevator is traveling, to simulate actions scenes where the hero is anticipating enemies when the elevator stops, so he/she can sneak out and either hide, or attack from a hidden vantage point (think Die Hard, or literally any 80s action movie ever).

I’ll definitely look into these alternative approaches for my other elevators!

1 Like

Hello again! :slight_smile:

As I continued working on the previous solution, I’ve bumped into some problematic issues with how the timeline behaves, namely that the timeline tends to “linger” for quite a while towards the end, which delays significantly all other events that need to trigger, such as the doors opening, and the messaging system, so I figured I’d start fresh with a different approach following your suggestions.

I managed to replicate and adapt your blueprint with my existing variables, but i’m not sure where the function OnRep plugs into. Does it go into the event tick? So far when calling the elevator, it returns false on the SrvMoveElevator first branch, to which i input the integer corresponding to the floor i want the elevator to move to.






You shouldn’t ever need to call an ONRep function directly. There job is to execute only when its bound Repnotify variable value changes.

Your NEW FLOOR variable needs to be set to RepNotify. When you do this the engine will create an empty OnRep_NewFloor function.

Got it! But for some reason the elevator is still unresponsive, as in the elevator up and down events are not firing, which tells me that the engine is having troubled accessing the function somehow… what am i missing?


Screenshot 2024-08-20 235333

Elevator Actor needs to Replicate

Defaults → Replicates

Do Not tick Replicate Movement

Looks like the actor is replicated, with no movement… what else could i be overlooking?

Screenshot 2024-08-21 124928

Do the same print string setup I used on the Srv Move Elevator event.

This will tell you if the event is being called on the server. If it isn’t called then the Onrep function wont fire.

Srv Move Elevator needs to replicate (Run on Server).


General flow here is the client interacts with the local elevator. That Elevator calls its server version (Srv Move Elevator). The server elevator “Sets” the New floor repnotify variable.