FlxG.Collide angle dependant?

65 views
Skip to first unread message

PTR

unread,
Jun 29, 2015, 1:58:31 PM6/29/15
to haxef...@googlegroups.com
I'm using two groups + a custom callback function. I am also rotation one of my groups' members in different angles and using the velocity to move them on high speed (500px/sec). The problem is, that the collision does not work in specific angles, while it works in other angles. How is that? FlxG.Overlap seems to work properly, but I need the FlxG.Collide because I need the physical interaction. Any advice or trick to fix or bypass it?

PTR

unread,
Jun 29, 2015, 6:24:35 PM6/29/15
to haxef...@googlegroups.com
Looks like it is a problem with the FlxObject.separate function, whilst FlxG.overlap returns true, FlxObject.separate does not.

Gama11

unread,
Jun 30, 2015, 6:42:41 AM6/30/15
to haxef...@googlegroups.com, zang...@gmail.com
Sounds strange, got an example?

PTR

unread,
Jun 30, 2015, 7:23:27 AM6/30/15
to haxef...@googlegroups.com, zang...@gmail.com
private var _bulletGroup:FlxSpriteGroup;
private var _enemyGroup:FlxTypedGroup<Enemy>;

override public function update():Void 
{
super.update();
hero.update();
_bulletGroup.update();
_enemyGroup.update();
FlxG.overlap(_bulletGroup, _enemyGroup, bulletHitEnemyCallBack); ///returns true always when needed.
FlxG.collide(_bulletGroup, _enemyGroup, bulletHitEnemyCallBack); ///returns false even if the overlap returns true
FlxG.collide(hero, _enemyGroup); ///works, no such problem.
}
I have removed the unnecessary parts, so basically this is how I'm using the functions. Worth to mention that the bullets are going at a 500frame/sec using the veclocity variable. I always call the super.update() before my logic.

On the second thought, it can be caused by the high speed of the bullet, but then how is the overlap returns true? I have tried to set the FlxObject.SEPARATE_BIAS to 1 (default 4), but didn't affect the outcome.

Gama11

unread,
Jun 30, 2015, 10:34:49 AM6/30/15
to haxef...@googlegroups.com, zang...@gmail.com
You've removed a lot more than just the unnecessary parts. That code snippet doesn't compile on its own. ;)

PTR

unread,
Jun 30, 2015, 12:34:42 PM6/30/15
to haxef...@googlegroups.com, zang...@gmail.com
Ah yes, sorry, in the meantime, I have found the problem. I got used to separating graphics from logic, but in HaxeFlixel I don't do it, but I still called update on groups, aka updating some instances twice. That resulted in a very buggy collision detection AND a faster pace.

Jimmy JimJim

unread,
Jun 30, 2015, 12:37:54 PM6/30/15
to haxef...@googlegroups.com
I thought haxeflixel used AABB collision detection which doesn't support rotated sprites? The image can rotate but the collider wouldn't be rotated with it.
Reply all
Reply to author
Forward
0 new messages