Dear community, have BETTER tri-directional moving floors

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
GooberMan
Posts: 1336
Joined: Fri Aug 08, 2003 12:57 am
Location: Helsinki, Finland

Dear community, have BETTER tri-directional moving floors

Post by GooberMan »

So. Another tech demo WAD from me. Has it really been that long since STARBOX.WAD?

Earlier this morning, I got an idea on how I could implement moving 3D floors. Except they wouldn't be 3D floors as such. They'd be a use of polyobjects with walkable mid textures. A bit of experimenting (and finding a Doomworld thread from last year) soon showed me the futility of my idea - that being that impassable polyobjects will push you out of the way. However, since I'd also planned on implemting height variation effectively, I'd also been playing around with sector heights in my polygon control sector. This gave me an interesting discovery - if I set my texture offsets to lower than the control sector's floor height, I didn't need walkable mid textures. The polygon would spawn with that sector's height. Or, in other words, it was entirely possible to replicate oldschool 3D floors purely with polyobjects.

So, the only line flags I set on my polyobject lines were doublesided, lower unpegged, and clip middle texture. This made my polyobject completely unblocking while moving. Combined with the texture offset and a control sector floor height set higher than the target sector floor height, I had a polyobject that would push me out of the way if I got in front of it but not if I stood on top of it.

Now, some might call that mission success. But from the start, I was programming some scripts with friction in mind. Being on a moving floor that slides away from me isn't good enough. I have to move with the floor. And this is the tricky part. To know if you're on a floor, generally these days you'd use an "Actor Hits Floor" thing. But that doesn't work. So you need to refer to linedefs. The script expects all exterior linedefs of your polyobject to be facing out. The script that activates on crossing it then checks which side it was activated from before determining if the player is on or off. Next, you need to know if the player's Z value matches the floor's Z value. To do this, I check against a dummy thing inside the control sector. You could use GetSectorFloorZ in the same manner, but you still need a dummy thing inside that control sector for reference. If the Z height matches, the player is on the floor and thus friction should be applied.

Using SetActorPosition was bad. It removed all freedom of moving on a platform. To implement friction, I needed to alter the player's velocity. Finding the correct velocity value was trial and error. I'm sure there's some mathematically correct way to find out the correct velocity to apply based on referring to the Doom movement code and plugging it in to an equation, but as it stands dividing the difference of the floor's previous position to it's current position by 10.7 gets something very close to the correct friction on the platform.

All that remains is to set up your polyobject's move path. The path I've set up moves tri-directionally - it moves on X and Y as a polyobject does, and it moves along Z at the same time thanks to altering the control sector.

Oh, and because I don't like showing off anywhere near enough, it is also multiplayer compatible.

The example WAD can be found here.

LIMITATIONS
  • You can't walk under the floor.
  • Things get screwy if your polyobject goes below the normal floor.
  • Rotational friction is not currently supported. There is no GetPolyobjAngle to compare against.
  • I'm disabling view bob when setting the velocity. I quite simply haven't checked if leaving it enabled will bob your view as the platform moves.
THE WAY FORWARD FROM HERE
  • Removing the sector height modification and simply changing the texture offsets.
  • To account for the now-missing height, anchor some invisible bridge things to the poly object.
  • See if we can't get a flat rendering over that 3D floor. Transfer_Heights trickery? Non-solid 3D floor trickery?
Last edited by GooberMan on Tue Jan 22, 2013 7:15 am, edited 1 time in total.
User avatar
Enjay
 
 
Posts: 27123
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Dear community, have tri-directional moving floors

Post by Enjay »

Very interesting and very smooth.

I did encounter a minor problem. I stepped too close to the edge of the platform and got the "sorry to see you leave message". However, I hadn't actually left the 3D floor so it kept moving but I was no longer being carried by it.

You may also be interested in the following thread where a different approach was taken. Polyobjects are not involved at all (actors and models are used instead) but perhaps there is some common ground in the way that the player is kept moving with the platform.

http://forum.zdoom.org/viewtopic.php?f=3&t=34434
User avatar
GooberMan
Posts: 1336
Joined: Fri Aug 08, 2003 12:57 am
Location: Helsinki, Finland

Re: Dear community, have tri-directional moving floors

Post by GooberMan »

Yeah, the hanging off the edge thing is a result of using linedefs instead of actor special things. Doomguy crosses a line when his exact centre crosses it. I'd have to have dummy lines outside that polyobject that are the same distance out as Doomguy's radius. But that sounds even more fragile to me - any additional mod on top of it will break that effect, not to mention requiring more setup.

I checked the topic. They're using SetActorPosition too. What I found with that was that it was killing all velocity (confirmed by checking the code and seeing it implemented as a teleport). And not only that, thanks to the linedef thing, if I did manage to move with setting the actor's position being a teleport and not a movement the line crossing was not happening and it was getting out of sync.

Of course, the advantage to doing it with polyobjects instead of models and actors is that you can make any arbitraty 3D platform with a bit of additional script jiggery-pokery (that's totally a technical term).

EDIT: Actually, I can go one further. With some additional scripting jiggery-pokery, I can make it work for any actor that gets on the platform. Assign temporary IDs to actors that get on that don't already have a TID, put those in a list/array, and do exactly what I'm doing now. I haven't looked yet, but are two dimensional arrays supported in ACS? Because that'd make everything significantly easier.
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: Dear community, have tri-directional moving floors

Post by Gez »

GooberMan wrote:A bit of experimenting (and finding a Doomworld thread from last year) soon showed me the futility of my idea - that being that impassable polyobjects will push you out of the way.
It's recent enough not to have been mentioned, but 3D mid tex polyobjects are possible now. There is a good example in the recently-released ZDCMP2, warp to 0 5000 and look at the dig site fort doors.


The trick to keep in mind is that collision detection with 3D mid tex is done vertically with the linedef's own sector (rather than the sector the mobj is in). That means for a 3D mid tex polyobject that the hold sector must have floor and ceiling heights allowing at least as much allowance as the sector(s) in which the polyobject will be -- otherwise, the polyobject will block you, not by its walls but by its floor or ceiling.
User avatar
GooberMan
Posts: 1336
Joined: Fri Aug 08, 2003 12:57 am
Location: Helsinki, Finland

Re: Dear community, have tri-directional moving floors

Post by GooberMan »

Walkable midtex poly objects just weren't working for me. I forgot to mention that the poly object just won't move if you're standing on top of a midtex polyobj. And if you set the start point to crushable, then you get problems where you start getting damaged for no apparent reason.
Blzut3
 
 
Posts: 3211
Joined: Wed Nov 24, 2004 12:59 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: Dear community, have tri-directional moving floors

Post by Blzut3 »

GooberMan wrote:standing on top of a midtex polyobj.
Please keep in mind that standing on moving 3dmidtex polyobjs is undefined at the moment, so even if you were to somehow get it to work a future version of ZDoom may break it. If you want to take a stab at defining this behavior here's my patch of semi-working polyobj friction: http://forum.zdoom.org/viewtopic.php?t= ... 27#p598827
User avatar
GooberMan
Posts: 1336
Joined: Fri Aug 08, 2003 12:57 am
Location: Helsinki, Finland

Dear community, have BETTER tri-directional moving floors

Post by GooberMan »

I made it better! Here's the reference WAD.

So I solved the walking under it problem. Not by using bridge things. No, that would remove the arbitrary nature of polyobjects. I got to thinking - if the polyobject I was using was just transferring sector heights, what would happen if I applied a 3D floor to the polyobject control sector? The answer was that SHIT WOULD JUST WORK!

You can now walk over and under the walking floors. I've cleaned the scripts up a tiny bit, and applied the texture offsetting I was talking about. The polyobject's control sector height no longer changes one bit, however the 3D floor applied to it does. Textures are offset to match that 3D floor.

However, the linedef method is now starting to show its horrible flaws. Namely, if a polyobject moves and an actor crosses above/below it while standing still it doesn't trigger the line crossed behaviour. Not that anyone's had to care about such things before.

This is almost "right". I want to solve the hop on/hop off stuff. To do that, I need to remove the linedef triggers. Which means I need to have the transferred heights trigger the "Actor hits floor" thing specials. Feel free to experiment and contribute, anyone who can map and knows ZDoom well.
Locked

Return to “Editing (Archive)”