# Hittesting

**URL:** https://forum.kirupa.com/t/hittesting/322453
**Category:** flash
**Created:** [May 21, 2011, 11:05am UTC](https://forum.kirupa.com/t/hittesting/322453 "2011-05-21T11:05:38Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![12abhi12](https://avatars.discourse-cdn.com/v4/letter/1/9f8e36/32.png) [@12abhi12](https://forum.kirupa.com/u/12abhi12)
#### Post date: [May 21, 2011, 11:05am UTC](https://forum.kirupa.com/t/hittesting/322453/1 "2011-05-21T11:05:38Z")

</div>

I have a mc (the\_hero) which when collides with another mc (enemy\_n), reverses its direction.

```php
if (enemy_n.hitTestObject(the_hero)) {
	if (enemy_n.hitava==true) {
		enemy_n.angle4=Math.floor(Math.atan2(the_hero.y-enemy_n.y,the_hero.x-enemy_n.x)*(180/Math.PI));
		xspeed*=((-1)*Math.abs(Math.cos(enemy_n.angle4*(Math.PI/180))));
		yspeed*=((-1)*Math.abs(Math.sin(enemy_n.angle4*(Math.PI/180))));
	}
	enemy_n.hitava=false;
} else {
	enemy_n.hitava=true;
}

```

The problem is, that on continuous multiple collisions, the hero penetrates the enemy. Any way to not let that happen?
