Check if Player hit ground and not ceiling.

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
LOZ_98
Posts: 67
Joined: Thu Mar 22, 2018 7:46 pm
Graphics Processor: nVidia (Modern GZDoom)

Check if Player hit ground and not ceiling.

Post by LOZ_98 »

Hi there.

I'm having this little trouble trying to Check when players hits the ground, I've already figured out some way to check if distance between player and Floor is equal to 0 using this :

Code: Select all

If(GetActorZ (0) - GetActorFloorZ (0)==0.0)
 {
  Print(s:"Player is Grounded");
 }
The problem is that this condition seems to get triggered also when the player hits the ceiling, as if the ceiling is treated as Floor or something, but I only want to check for Floor exclusively, Is there a way to do this ? Thanks in advance.
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Check if Player hit ground and not ceiling.

Post by Blue Shadow »

Try enclosing the GetActorZ (0) - GetActorFloorZ (0) part within parenthesis, like this:

Code: Select all

If((GetActorZ (0) - GetActorFloorZ (0))==0.0)
   ^                                  ^
The idea behind that is to make sure the calculations are done first before performing the comparison.
User avatar
LOZ_98
Posts: 67
Joined: Thu Mar 22, 2018 7:46 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Check if Player hit ground and not ceiling.

Post by LOZ_98 »

That simple ? lol thanks, I'll try it.
Post Reply

Return to “Scripting”