"Sticking" player to floor when going down stairs?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Nash
 
 
Posts: 17487
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

"Sticking" player to floor when going down stairs?

Post by Nash »

Does anyone know a simple way to "glue" the player to the floor when walking down stairs? Currently with a fast moving player, you will just overshoot the stairs and end up floating in the air when descending stairs.

ZScript and custom player pawn welcome.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49226
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: "Sticking" player to floor when going down stairs?

Post by Graf Zahl »

Not easily. The movement logic already contains code that allows an actor to step down stairs, but this logic will fail if you overshoot the stairs due to too high velocity, because this will be considered moving over a dropoff which results in gravity pulling you down.
User avatar
Zan
Posts: 338
Joined: Sat Oct 22, 2016 12:43 pm
Location: The depths of Hedon.
Contact:

Re: "Sticking" player to floor when going down stairs?

Post by Zan »

grunt grunt grunt grunt grunt :^)

I agree it would be cool to have something like this in.
User avatar
The Zombie Killer
Posts: 1528
Joined: Thu Jul 14, 2011 12:06 am
Location: Gold Coast, Queensland, Australia

Re: "Sticking" player to floor when going down stairs?

Post by The Zombie Killer »

This resource from 2016 may be a good starting point. Note that it's written in ACS so it'd first have to be ported to a custom player class.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: "Sticking" player to floor when going down stairs?

Post by Matt »

One possibility I can imagine is to check, every tick:
- previous floorz
- current floorz
- previous onground status

and use setz to snap the player to the current floorz if
- the current floorz is less than previous floorz
- the difference does not exceed maxstepheight
- previous onground status is true
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49226
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: "Sticking" player to floor when going down stairs?

Post by Graf Zahl »

That won't do anything because the engine already does it. Like I said above, the problem comes when the player overshoots the next lower stair and the difference between z and floorz is already LARGER than maxstepheight.
User avatar
Nash
 
 
Posts: 17487
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: "Sticking" player to floor when going down stairs?

Post by Nash »

I've been thinking a bit about this. I don't think this will ever work script-side. The player's view will "snap" down to the next lower step. There's some hardcoded stuff to handle vertical camera interpolation, but altering the player's Z via brute force through scripting will most probably violently jitter the camera downwards.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49226
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: "Sticking" player to floor when going down stairs?

Post by Graf Zahl »

What you want here wouldn't even work in real life.
Imagine some person running full speed across some stairs. They'd jump across a lot of steps as well because in order to step down properly you have to move slowly.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: "Sticking" player to floor when going down stairs?

Post by Matt »

......huh. That is surprisingly subtle. So that's why stuff seems to drop just a bit faster than midair gravity would suggest....
Post Reply

Return to “Scripting”