Entity IsOnGround issue

Hello,
I haven’t coded in Lua in like a year and a half now but I’m just playing around with random stuff as I’m bored. I’m trying to make it so that when ever an entity (vphysics) touches the ground I add velocity to shoot it back up into the air. It seems that when ever I call self:IsOnGround() or self:OnGround() it returns false (even though the prop is clearly laying on the ground not moving). I’ve also tried self:GetGroundEntity() but that returns NULL instead of world. Another thought I had was to get the distance between the world and entity but that seems highly unstable and I don’t even think its possible. I have all of this in the init.lua for prop_phys under ENT:Think(). Any suggestions would be nice, thanks!

If you get the position of a player; the Z position is at the feet / touching the ground.

If you want something to react when it hits the ground, you can use something such as OnPlayerHitGround; which would be for players.

Did you overwrite OnGround in your game-mode? There are functions which are: ENTITY:IsOnGround(), ENTITY:OnGround()

ENT:OnLandOnGround( ) for nextbot.

I just tried: print( Entity( 1 ):OnGround() ); and it reported true when I was on the ground, false when I wasn’t, and for control, false when I was out of the map.

print( Entity( 1 ):GetGroundEntity( ) ) will return NULL if it’s the world, but it’ll give you the prop if you’re on a prop.

See if it works for players first.

I did try it with a few frozen / welded entities and npcs with them reporting false / null.

IsOnGround and OnGround only works for stuff with a physics shadow AKA not vphysics.

You have to use ENT:PhysicsCollide(data, phys)

Hi, sorry if my question wasn’t clear. I’m not trying to get if the players on the ground, I’m trying to get if a prop is on the ground. I did try pl:IsOnGround() and that reported true and false correctly. I haven’t overridden the function either. In the wiki it doesnt say that its just for player entity’s either so I’m just all around confused.

[editline]31st December 2013[/editline]

Ahh JetBoom, perfect! Working on a gamemode I left off last year, but I lost some files so I’m trying to re-figure this out. I think that’s how i got it to work before. Thanks