I'm starting to make a platformer and I cannot get the gravity to work right, if the block spawns below him, he will levitate above it and be able to move side to side, but if he "falls" onto it from the start, he falls until he hovers about 10 pixels above it.
Also, if he is "standing"(leviatating) on the platform, he doesnt fall down when he steps off of it. Any help?
public void checkFall()
{
if (onGround()){
gravity = 0;
acceleration = 0;
}
else
{
fall();
}
}
public boolean onGround()
{
int spriteHeight = getImage().getHeight();
Actor ground = getOneObjectAtOffset(0, getImage().getHeight()/2, Platforms.class);
if(ground == null)
{
return false;
}
else
{
moveToGround(ground);
return true;
}
}
public void moveToGround(Actor ground)
{
int groundHeight = ground.getImage().getHeight();
int newY = ground.getY() - (groundHeight + getImage().getHeight())/2;
setLocation(getX(), newY);
}

