About Store Forum Documentation Contact



Post Reply 
Ground detection
Author Message
smashthewindow Offline
Member

Post: #1
Ground detection
How does the engine detects if a character is on ground or not?
I'm currently trying to implement the on ground function for other shapes than a capsule (specifically a ball.).
05-28-2013 10:02 PM
Find all posts by this user Quote this message in a reply
AndrewBGS Offline
Member

Post: #2
RE: Ground detection
That's really simple; inside the player class, you have this:

T.ctrl.onGround() - tells you if player is ground, funny.
Or maybe T.cctrl.actor.onGround(), not sure.
05-28-2013 10:25 PM
Find all posts by this user Quote this message in a reply
smashthewindow Offline
Member

Post: #3
RE: Ground detection
(05-28-2013 10:25 PM)AndrewBGS Wrote:  That's really simple; inside the player class, you have this:

T.ctrl.onGround() - tells you if player is ground, funny.
Or maybe T.cctrl.actor.onGround(), not sure.

Yes, but please read the original post carefully - I'm not asking about the default controller class' exposed functions.
I'm trying to implement my own custom controller class that can take not capsules but balls as it's shape.
(This post was last modified: 05-28-2013 10:36 PM by smashthewindow.)
05-28-2013 10:35 PM
Find all posts by this user Quote this message in a reply
Scarlet Thread Offline
Member

Post: #4
RE: Ground detection
Not sure of the official way but in my non engine specific approach, I would check for a collision with AG_TERRAIN (or any) and if the normal of the collision gives a walkable slope then it would be considered on ground. That's how I would do it. Not sure if you can get the normal from the collision in EE... I'm at work so I can't check right now.

Alternatively perform a raycast downward from the centre of your custom controller to just a tiny pit past the bottom and get the normal from that. Same deal from there on.
(This post was last modified: 05-29-2013 06:18 AM by Scarlet Thread.)
05-29-2013 06:17 AM
Find all posts by this user Quote this message in a reply
smashthewindow Offline
Member

Post: #5
RE: Ground detection
(05-29-2013 06:17 AM)Scarlet Thread Wrote:  Not sure if you can get the normal from the collision in EE...
You can't from cuts callback.

(05-29-2013 06:17 AM)Scarlet Thread Wrote:  Alternatively perform a raycast downward from the centre of your custom controller to just a tiny pit past the bottom and get the normal from that. Same deal from there on.
I have no idea why but the sweep raycast seems to be very unstable (Doesn't always hit). I'll post more about it later.

EDIT: It seems to not report a hit when the ball is not moving.
(This post was last modified: 05-29-2013 12:42 PM by smashthewindow.)
05-29-2013 11:54 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Ground detection
Due to Physics.skin and numerical precision imperfection the actor may intersect with the ground slightly, and sweeping will not detect objects which the source is already intersecting.

For Controller I use Sweep and give the source as Actor's capsule but thinner (capsule.extend(-value))
05-31-2013 01:34 PM
Find all posts by this user Quote this message in a reply
smashthewindow Offline
Member

Post: #7
RE: Ground detection
(05-31-2013 01:34 PM)Esenthel Wrote:  Due to Physics.skin and numerical precision imperfection the actor may intersect with the ground slightly, and sweeping will not detect objects which the source is already intersecting.

For Controller I use Sweep and give the source as Actor's capsule but thinner (capsule.extend(-value))

Ah ok, that seems to be a better solution.
A temporary workaround was to record the collision callbacks and just resetting the on ground value according to whether or not the physics was updated in the previous frame.
(This post was last modified: 05-31-2013 02:27 PM by smashthewindow.)
05-31-2013 02:26 PM
Find all posts by this user Quote this message in a reply
Post Reply