View Single Post
SpannerSpammer
Member
Join Date: Mar 2006
Old 09-01-2016 , 02:11   Re: Is it possible to detect if a player is touching the ceiling/sky with their head?
Reply With Quote #6

Don't use the TextureType route, it's an unreliable method (mappers can use custom textures
and unknown textures will cause the code to return the default material, which is Concrete).

Try this:
Do a Traceline from the Player's eye position straight up for 8192 units.

Get the vecEndPos, and do a point contents check on that origin.

If you get CONTENTS_SKY at that position, then get the Player's
pev->absmax value and subtract the z-axis (vertical component) value
from the vecEndPos z-axis. If the difference is less than about 0.1 - 0.05,
then the player is definitely touching the skybox.

(What you're checking here is to see if the Player's bounding box and the
ceiling intersect, more or less)

As for your wall problem: Traceline + Point Contents. If the result is not
CONTENTS_SOLID then it's not something your player should be able
to climb, unless it's a ladder.
__________________
[NeoTF|DEV]SpannerSpammer-[AoE]-
NeoTF Development Team.
http://steamcommunity.com/groups/neotf
SpannerSpammer is offline