generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How to check if Player is Grounded?

Previous Thread :: Next Thread 
ZQFMGB12 is not online. ZQFMGB12
Joined: 07 Aug 2010
Total Posts: 208
23 Jul 2014 08:52 PM
I need a method or algorithm to check if a player is grounded. A player is grounded when there is a solid part beneath the player's feet.

I know that there is an event that belongs to Humanoid that fires (Enum.HumanoidStateType.Landed) when the player is lands, but I feel that the event is inaccurate.

For example, if a player spin jumps (custom scripted action) and there is a part right on top of the player, the grounded event won't fire and the script won't work. This is because in the script, a spin jump has a debounce variable and it becomes false when the player is grounded.

Does anybody have any ideas?
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
23 Jul 2014 08:52 PM
ray casting
Report Abuse
IAmTheRolo is online. IAmTheRolo
Joined: 12 Nov 2013
Total Posts: 859
23 Jul 2014 08:53 PM
raycast
Report Abuse
ZQFMGB12 is not online. ZQFMGB12
Joined: 07 Aug 2010
Total Posts: 208
23 Jul 2014 08:53 PM
elaborate please?
Report Abuse
Tynexx is not online. Tynexx
Joined: 11 Jul 2012
Total Posts: 1559
23 Jul 2014 08:53 PM
And/Or maybe magnitude
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
23 Jul 2014 08:54 PM
'And/Or maybe magnitude'

yes loop through every single item in the game instead of sending a line to see if there is anything 2.5 blocks below the torso other than the legs
what could go wrong
Report Abuse
ZQFMGB12 is not online. ZQFMGB12
Joined: 07 Aug 2010
Total Posts: 208
23 Jul 2014 08:54 PM
Will ray casting work even though the part is rotated in any of the three axes?
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
23 Jul 2014 08:56 PM
It'll work as long as you check if something is below the feet

It won't matter what it is or how its rotated as long as you check directly below the feet

Would probably want to make it check if said brick is cancollide = true though
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
23 Jul 2014 08:56 PM
Not really :L
Report Abuse
FertileTurtle is not online. FertileTurtle
Joined: 04 Dec 2012
Total Posts: 1414
23 Jul 2014 08:57 PM
char.Humanoid.Changed:connect(function()
if char.Humanoid.Jump.Value == true then
repeat wait() until char.Torso.Velocity.Y == 0
print'Ground'
end
end)

I tested it and it works fine, it has about a second delay though.
Report Abuse
FertileTurtle is not online. FertileTurtle
Joined: 04 Dec 2012
Total Posts: 1414
23 Jul 2014 08:58 PM
char.Humanoid.Changed:connect(function()
if char.Humanoid.Jump == true then
repeat wait() until char.Torso.Velocity.Y == 0
print'Ground'
end
end)
Report Abuse
ZQFMGB12 is not online. ZQFMGB12
Joined: 07 Aug 2010
Total Posts: 208
23 Jul 2014 09:00 PM
That won't work because not all extra movements I'm including make Humanoid.Jump become true.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
23 Jul 2014 09:01 PM
So long as they do not fall over, you can just use the ray:

Ray.new(torso.Position, Vector3.new(0, -3.05, 0))

and it will return if they are grounded (Most of the time) (Will not work if they are not fully on a part) (Will not work if they are standing on something with lots of small holes in it)
Report Abuse
ZQFMGB12 is not online. ZQFMGB12
Joined: 07 Aug 2010
Total Posts: 208
23 Jul 2014 09:04 PM
I don't plan to be too evil with platform placing yet (0.2x0.2x0.2 stud platforms) because of the new awkward traction physics on Roblox
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
23 Jul 2014 09:06 PM
You can also make the entire collidable world invisible and make the fancy visual stuff non-collide (Or use CSGs when they eventually appear) :P
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
23 Jul 2014 09:08 PM
@Not
0.2 x 0.2 x 0.2 blocks set to cancollide = false still bug your character out when you touch them sometimes
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
23 Jul 2014 09:09 PM
@128GB: Oh, yeah. I forgot this was ROBLOX.
Report Abuse
ZQFMGB12 is not online. ZQFMGB12
Joined: 07 Aug 2010
Total Posts: 208
23 Jul 2014 09:21 PM
Raycasting works beautifully...for now!

Wasted 120 robux trying to fix some animations before ray casting.

Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
23 Jul 2014 09:26 PM
If I were to do this, I would do something with the "FreeFalling" and "Running" events of the Humanoid.
Report Abuse
Luc599345 is not online. Luc599345
Joined: 25 Jul 2008
Total Posts: 1169
23 Jul 2014 09:38 PM
Ask him if he was mean to his parents
Report Abuse
ZQFMGB12 is not online. ZQFMGB12
Joined: 07 Aug 2010
Total Posts: 208
23 Jul 2014 09:42 PM
@blockhoo

Been there, done that, the enums aren't very accurate for what I'm trying to accomplish. For example, when you spin jump, my movement script sets a variable to false and when you touch the ground, it becomes true. Say you spin jump right under a part. If I used Enums, the events wouldn't fire because the player appears to have not jumped, but the variable is still set to false (which disallows jumping).

I think ray casting for now is the superior option.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image