# A priori collision detection

**URL:** <https://forum.kirupa.com/t/a-priori-collision-detection/309349>\
**Category:** Uncategorized\
**Created:** [May 12, 2010, 5:02pm UTC](https://forum.kirupa.com/t/a-priori-collision-detection/309349 "2010-05-12T17:02:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nim](https://avatars.discourse-cdn.com/v4/letter/n/67e7ee/32.png) [@Nim](https://forum.kirupa.com/u/Nim)\
**Post date:** [May 12, 2010, 5:02pm UTC](https://forum.kirupa.com/t/a-priori-collision-detection/309349/1 "2010-05-12T17:02:17Z")

</div>

In **platform games** when you make your character jump you need **a priori collision detection** in order not to see your character standing “in” the ground.

So when the character starts falling you need to check the next Y position of your character for a collision, and if collision is true, to set character **exactly on** ground.

In order to accomplish this, by the time the next Y character location is colliding with ground, you need to know the distance between the character and the ground line underneath him.

If you know the distance you just make character.y+=distance

**How am I going to know this distance?**

(I have figured out a function that estimates the distance with multiple hitTestPoint collision checks in a loop. But still, it’s an estimation and the character doesn’t always stop **exactly on** ground.)

Is there any other **better** way?

Thx in advance
