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
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
| |
|
| |
|
ZQFMGB12
|
  |
| Joined: 07 Aug 2010 |
| Total Posts: 208 |
|
| |
|
Tynexx
|
  |
| Joined: 11 Jul 2012 |
| Total Posts: 1559 |
|
| |
|
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
|
  |
| 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
|
  |
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 23 Jul 2014 09:09 PM |
| @128GB: Oh, yeah. I forgot this was ROBLOX. |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|