mercredi 30 septembre 2015

Faster method than Point.distance to calculate collision between objects?

I'm developing a game where I have lots of collisions, and it rapidly came to notice that my bottleneck is this line:

if(Point.distance(_point1, _point2) < collisionDistance){
  //do stuff
}

where _point1 and _point2 are static variables that store the positions of objects that could collide if the collisionDistance is low enough.

Do you know of any more performant method to check a simple collision between two circles?.

Aucun commentaire:

Enregistrer un commentaire