# Stuck in ground with hitTest();

**URL:** https://forum.kirupa.com/t/stuck-in-ground-with-hittest/87121
**Category:** programming
**Created:** [April 18, 2005, 5:56pm UTC](https://forum.kirupa.com/t/stuck-in-ground-with-hittest/87121 "2005-04-18T17:56:15Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Ferdi](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ferdi/32/689_2.png) [@Ferdi](https://forum.kirupa.com/u/Ferdi)
#### Post date: [April 18, 2005, 5:56pm UTC](https://forum.kirupa.com/t/stuck-in-ground-with-hittest/87121/1 "2005-04-18T17:56:15Z")

</div>

Hey all!  
My character gets stuck in the ground with the hitTest() function.  
What I’m trying to accomplish is to make him walk smoothly to the ground.  
I’ve attached the swf if you want to take a look. Otherwise, this is the code:

```php

onClipEvent(load) {
	  setGravity = 0.5;
	  gravity = setGravity;
}
onClipEvent(enterFrame) {
	  groundhit = _root.hill.hitTest(_x, _y, true);
 
	  if (!groundhit) {
		   gravity += setGravity;
		   _y += gravity;
	  } else { 
		   _y -= gravity;
		   gravity = setGravity;
	  }
 
	  // KEYS
	  if (Key.isDown(Key.RIGHT)) {
		   _x += 2;
	  }
	  if (Key.isDown(Key.LEFT)) {
		   _x -= 2;
	  }
	  if (Key.isDown(Key.UP) || Key.isDown(Key.SPACE)) {
		   gravity = -10;
	  }
}

```

Thanks a lot in advance!
