Frictional Games Forum (read-only)

Full Version: [PoC] Elevators
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This seems to be turning into a trend. Here I am extending what I learned about Sequences from the making of the last PoC into making a working elevator.

[Image: ?interpolation=lanczos-none&output-forma...olor=black]
[Image: ?interpolation=lanczos-none&output-forma...olor=black]

As usual, you can grab the map and associated files on the Steam Workshop. EDIT: This and my other PoC mods are now available on MoDDB as well.

An interesting thing I found out about doing elevators is, when I looked at the examples that are in SOMA itself, the few that I could find fell into one of two categories:

  1. The elevator unit itself was stationary while things moved around it, simulating the experience of riding an elevator. When the sequence was complete, the player is teleported to an identical position further along. (Theta)
  2. While the elevator moved, the player had a story-reason to be fixed in place during the entire elevator ride. (Omicron)

The programming behind the second one revealed why all the elevators in SOMA weren't the proper "elevator-unit-moves-with-the-player-inside" option, as in order to get the player to move with the elevator, you have to move them along with the elevator relative to their position in relation to the elevator itself. This has the nasty side-effect of leaving the player unable to move at all during the sequence. What's more, if you simply has the elevator move independently of the player, the player's camera has that weird "fall-then-bob-continuously" quirk that games have where the physics doesn't directly support this kind of action.

So yeah, it will take quite a bit more tinkering as well as some clever physics workarounds to enable that kind of elevator action, so until someone comes up with it (there are games that do it, so the how-to's gotta be out there somewhere), we're stuck with using one of these two categories.
Actually, in a lot of video games, that first option occurs. The same mechanic was used in Amnesia, and is spoken about in the developer commentary about it. Great work! I was going to tackle this issue but procrastination kicked in :p

If you get a moment, could you put up an article about this on the wiki? While your Workshop mod will be beneficial for copy-pasting, some users are unable to access the Workshop. Furthermore, some people may want to learn how sequences work and may learn greater from actually reading and implementing rather than simply looking at code Smile
(10-26-2015, 11:11 AM)Modulator Wrote: [ -> ]Actually, in a lot of video games, that first option occurs. The same mechanic was used in Amnesia, and is spoken about in the developer commentary about it. Great work! I was going to tackle this issue but procrastination kicked in :p

Oh for sure. I was only sort of surprised to find out that was the case. I do know that some 3D games have the capability to be on a platform that is actually moving and still retain full motion, but they generally appear to be the exception rather than the rule, and I'd imagine those games have customized physics engines in order to do so.

I mean, it doesn't sound like it would be difficult in theory. Just have it so that when your character is standing on a platform, when that platform enters motion, have the player's character body lock its local transforms to be in reference to the platform rather than the world as a whole, then perform input and velocities with the new reference in mind. But I guess that if that were so easy, then there would be a whole lot more games doing it. Tongue

(10-26-2015, 11:11 AM)Modulator Wrote: [ -> ]If you get a moment, could you put up an article about this on the wiki? While your Workshop mod will be beneficial for copy-pasting, some users are unable to access the Workshop. Furthermore, some people may want to learn how sequences work and may learn greater from actually reading and implementing rather than simply looking at code Smile

Yeah, as jens posted, Sequences already have a fairly comprehensive page detailing their usage. The only thing it could really benefit from is a practical example of their application, and I've put up two of them now. Tongue
Ahh yes, I keep forgetting that there is more than just the Community section of the wiki, which is quite lazy of myself to do so x)
One thing you could do is work out of the position of the player relative to some point of the elevator at the start of the elevator. Then, teleport the player's body to an area of the map which is identical to the elevator the player is in for the duration of the elevator ride.
However, instead of putting the camera on the player's head, use the player's offset from the off map position and the offset from the elevator initially to place the camera where the player would be if he was in the elevator.
Then at the end, just set the position of the player to where it should be given the camera's current position. That way you don't need to move the map around the elevator, you can simply move the elevator and update the camera once a frame for the duration of the ride.

Portal 2 used this approach for the opening sequence in the stasis room with it crashing into stuff iirc.
That is the exact approach used in the second category I talked about above. In fact, there are a couple of Entity functions available in the HPL3 API to enable that kind of behavior. First is the Entity_GetDeltaToEntity function, which gets the offset of one entity relative to another in the form of a cVector3f. Then an overloaded version of the Entity_PlaceAtEntity function allows using that offset to move an entity to a position that would put it at the same relative offset. It's implemented in the way that, at the start of the Sequence step where the elevator is triggered to move, the delta is calculated between the player and the elevator, then during each Update step, that delta is used to put the player in the same position relative to the elevator.

And that's the approach that has the side-effect of overriding player input in such a way that during the elevator ride all they can do is look around, which is why during the times in SOMA that used this approach, the player was given a story-based reason to not be able to move. (e.g. Being strapped into the chair during the descent into the abyss.)

I suspect there might be a way to achieve player motion during the elevator ride, but it would involve changing up the logic behind handling player input, which for my PoC maps wasn't something I wanted to mess with, but might be something I look into later down the line. (And I haven't had a thorough look into the files that handle regular movement yet, so for all I know that part of the code might be locked behind the API wall.)