SRB2 Message Board  

Go Back   SRB2 Message Board > Sonic Robo Blast 2 > Editing > Editing Help

Reply
 
Thread Tools Search this Thread
Old 06-22-2017   #1
Yacker
Metallic
 
Yacker's Avatar
Default Find the floor beneath a player?

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 by Yacker; 06-22-2017 at 02:48 AM.
Yacker is offline   Reply With Quote
Old 06-22-2017   #2
Monster psychic cat
 
Monster psychic cat's Avatar
Default

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.
__________________
Quote:
*Sonikku shoots David Bulmer*

Last edited by Monster psychic cat; 06-22-2017 at 03:36 PM.
Monster psychic cat is offline   Reply With Quote
Old 06-22-2017   #3
Monster Iestyn
Friendly Neighbour-Hood
Moderator
 
Monster Iestyn's Avatar
Default

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.
Monster Iestyn is offline   Reply With Quote
Old 06-22-2017   #4
Yacker
Metallic
 
Yacker's Avatar
Default

Oh...for what ever reason I thought floorz didn't work with FOFs or slopes. Thanks
Yacker is offline   Reply With Quote
Old 06-22-2017   #5
Zwip-Zwap Zapony
Please just call me Zappy.
 
Zwip-Zwap Zapony's Avatar
Default

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 by Zwip-Zwap Zapony; 06-22-2017 at 02:54 PM.
Zwip-Zwap Zapony is offline   Reply With Quote
Old 06-22-2017   #6
Monster Iestyn
Friendly Neighbour-Hood
Moderator
 
Monster Iestyn's Avatar
Default

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 by Monster Iestyn; 06-22-2017 at 02:14 PM.
Monster Iestyn is offline   Reply With Quote
Old 06-22-2017   #7
Zwip-Zwap Zapony
Please just call me Zappy.
 
Zwip-Zwap Zapony's Avatar
Default

Quote:
Originally Posted by Monster Iestyn View Post
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.

Quote:
Originally Posted by Monster Iestyn View Post
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 by Zwip-Zwap Zapony; 06-22-2017 at 02:55 PM.
Zwip-Zwap Zapony is offline   Reply With Quote
Old 06-22-2017   #8
Monster psychic cat
 
Monster psychic cat's Avatar
Default

Quote:
Originally Posted by Monster Iestyn View Post
Anyway MFE_ONGROUND is a lie, that has nothing to do with actually being onground or not, it's ALWAYS on
I wonder what kind of situation happened internally to let this behavior happen.
__________________
Quote:
*Sonikku shoots David Bulmer*
Monster psychic cat is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:09 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.