Find the floor beneath a player?

Status
Not open for further replies.

Yacker

Metallic
Say I wanted to find the location of the floor beneath a player in the air, accounting for FOFs and slopes all. Is there a way I could do that?
 
Last edited:
In Lua, you can use player.mo.subsector.sector, which you can get its floor height with the variable floorheight. Not sure if it accounts for FOFs though, but there's a ffloors() variable that's a iterator function. player.mo.floorz.
 
Last edited:
Try player.mo.floorz, if you literally want the z position of the player's current "floor", whether they're actually on it or above it. This accounts for normal sector floors, FOFs, polyobjects, solid objects, probably slopes too?

The ceiling equivalent is player.mo.ceilingz, by the way.
 
Edit: According to Monster Iestyn, I'm wrong. Having just checked in SRB2, I'm still wrong.

Be aware that the "floorz" (and "ceilingz") values of objects are set to what's directly below (or above) the object's central point (unless I remember wrongly), where-as they actually have a collision box that lets them stand on/touch something that's not directly below/above their central point. (You know, like "tipping on the edge"-like stuff.)

This even gives a slight difference between the lowest Z position possible and the Z point directly beneath the central point of an object when standing on slopes, as the edge of the collision box hits a higher part of the slope than the central point of the object is above
. Thus you may want to check for "P_IsObjectOnGround(mobj)" instead, depending on the circumstances.
 
Last edited:
Actually I'm pretty sure in that case floorz is for the point on the hitbox the player would be touching the slope. So that, like, landing on ground code can actually work properly. (being <= floorz is considered onground for normal gravity)

Anyway MFE_ONGROUND is a lie, that has nothing to do with actually being onground or not, it's ALWAYS on except if you happen to be above a solid object. I plan to either kill it or totally rework it at some point in the future.
 
Last edited:
Actually I'm pretty sure in that case floorz is for the point on the hitbox the player would be touching the slope. So that, like, landing on ground code can actually work properly. (being <= floorz is considered onground for normal gravity) -
Well, I'll admit I don't know about that, I just remember someone suggesting to check if the player was on ground while their Z position was more than the ground position of the player, and I'd assume that central point would also be used for slopes in the exact same kind of way, along with slopes using the box-shaped collision for the Z position of objects.

Anyway MFE_ONGROUND is a lie, that has nothing to do with actually being onground or not, it's ALWAYS on except if you happen to be above a solid object. I plan to either kill it or totally rework it at some point in the future.
...Well I knew there was some kind of way to check if an object is on the ground, and there was a flag about it in object's userdata somewhere, so I assumed that was it. As you mention it now, I realize it wasn't a flag I remembered, but a function called P_IsObjectOnGround. My bad, I think.

...But looking at the source code of that command, what I remember learning about it from doesn't make sense, as it simply checks whether the object in question's Z position is less than or equal to its floor Z position (though it also accounts for being in goop not letting you stand and reverse gravity flipping floors and ceilings around). Now I'm just very, very confused about what I remember... Edit: Having just checked in SRB2, the "floorz" value does take slopes and standing on edges of sectors into account and all that stuff. Whoops.
 
Last edited:
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top