# Best way to hitTest particles?

**URL:** <https://forum.kirupa.com/t/best-way-to-hittest-particles/120304>\
**Category:** Uncategorized\
**Created:** [August 23, 2004, 5:40am UTC](https://forum.kirupa.com/t/best-way-to-hittest-particles/120304 "2004-08-23T05:40:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dunga](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@Dunga](https://forum.kirupa.com/u/Dunga)\
**Post date:** [August 23, 2004, 5:40am UTC](https://forum.kirupa.com/t/best-way-to-hittest-particles/120304/1 "2004-08-23T05:40:03Z")

</div>

I’ve set up a small mostly AS 2.0 particle engine, its pretty neat. My one problem is this: I want to make them hitTest walls/floors. I can do the actual hitTests just fine, the problem is that at a low velocity they just get stuck within the walls/floor, and just fall through slowly. Is there any good way avoid this?

Note: I am essentially remaking the engine in my signature in AS 2.0.

---

<div class="post-metadata">

**Author:** ![trundrumbalind](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/trundrumbalind/32/696_2.png) [@trundrumbalind](https://forum.kirupa.com/u/trundrumbalind)\
**Post date:** [August 23, 2004, 12:34pm UTC](https://forum.kirupa.com/t/best-way-to-hittest-particles/120304/2 "2004-08-23T12:34:41Z")

</div>

I’m not very experienced with using particles and physics etc in Flash but I think you have to calculate the **friction** of the walls and floor etc.

There’s a tutorial on this at [actionscript.org](http://actionscript.org) at:  
[http://www.actionscript.org/tutorials/intermediate/Flash\_Physics\_Study/index.shtml](http://www.actionscript.org/tutorials/intermediate/Flash_Physics_Study/index.shtml)

Hopefully this’ll help you out,  
Dave

---

<div class="post-metadata">

**Author:** ![Dunga](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@Dunga](https://forum.kirupa.com/u/Dunga)\
**Post date:** [August 24, 2004, 8:39pm UTC](https://forum.kirupa.com/t/best-way-to-hittest-particles/120304/3 "2004-08-24T20:39:49Z")

</div>

Hmm… that looks interesting. I’m not sure if its the friction that does it, but it seems to have some method of making sure it bounces.

---

<div class="post-metadata">

**Author:** ![Michael\_Chen](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@Michael\_Chen](https://forum.kirupa.com/u/Michael_Chen)\
**Post date:** [August 25, 2004, 12:35am UTC](https://forum.kirupa.com/t/best-way-to-hittest-particles/120304/4 "2004-08-25T00:35:30Z")

</div>

Yes, that may happen when the intersecting regions of the object and wall/floor is greater than the object’s current velocity.

To get around that problem I normally use if else statements rather than hitTest, or you should check if the ibject will collide the wall before assigning it’s new position. Do you see where I’m getting at?

---

<div class="post-metadata">

**Author:** ![Dunga](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@Dunga](https://forum.kirupa.com/u/Dunga)\
**Post date:** [August 25, 2004, 1:31am UTC](https://forum.kirupa.com/t/best-way-to-hittest-particles/120304/5 "2004-08-25T01:31:12Z")

</div>

Pretty much… like:

if(!wall.hitTest(particle.\_x+particle.xVel, particle.\_y+particle.yVel, true)){  
move particle  
} else {  
bounce particle  
}
