Hey all - still having some collision detection issues with the ground. Using 3dPlatformer as a model and trying to debug to the console…not able to figure this one out.
I have this function:
function OnGround()
{
return (collisionFlags == CollisionFlags.CollidedBelow != 0);
}
And then later, a movement function (which works fine except when I make it conditionally dependent on the OnGround function…)
function Update()
{
if (OnGround())
{
Move();
}
}
Just to test this, wrote this debug function:
if (collisionFlags == CollisionFlags.CollidedBelow != 0)
{
print("There is a collision below you.");
}
else
{
print("There is NO collision below you.");
}
Sure enough, when I am very high up from the ground, it says there IS something below my character…even when i’ve moved out to where there is no Terrain anywhere under my character’s feet at all! Any thoughts on how to remedy this? Thanks!
UPDATE
I tried this as well in the update function:
if (controller.isGrounded)
{
print("I am grounded!");
}
else
{
print("Nope, I am NOT grounded");
}
And even when my character is on the ground, this returns “Nope, I am NOT grounded”. I can not figure out why. Any thoughts as to a solution? I can’t get my fall/land scripts to work without this! Thanks.