Checking if an object is close to a ledge

Status
Not open for further replies.

742mph

My work is never done yet
I need a way to check using Lua if an object is teetering on a ledge or sudden drop in sector floor height. I considered using a variant of RedEnchilada's method of checking for blocking walls, but P_TryMove only supports horizontal movement, so it can't be used to check if the space slightly in front of and below an object is free. I also thought about replicating the teetering code used for the player character in p_user.c, but it looks much more complicated than necessary for something so simple. Any suggestions, resident coding geniuses?
 
I haven't checked to make sure, but I believe checking if P_FloorzAtPos(p.mo.x, p.mo.y, p.mo.z, p.mo.height) < p.mo.floorz-(24*FRACUNIT) will get the effect you want. That would basically mean the center of the object isn't touching the ground when the rest is. This would come after checking if the object itself is on the ground, of course.
 
Status
Not open for further replies.

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

Back
Top