You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into a problem with square shape. Euclidean distance formula works but not as I expected. When one square touch the corner of other suqare - collision does not happened :(
Code Example:
collision()
{
// this.collisions - many objects on scene (1 in this example)
// this one current object
for (var index in this.collisions) {
if (this == this.collisions[index]) continue;
if (this.distance(this.x, this.y, this.collisions[index].x, this.collisions[index].y) < this.width) {
console.log('sense');
break;
}
}
}
distance(x1, y1, x2, y2) {
const xDist = x2 - x1
const yDist = y2 - y1
return Math.sqrt(Math.pow(xDist, 2) + Math.pow(yDist, 2));
}
Can you explain why and how to solve it, please? Thank you
The text was updated successfully, but these errors were encountered:
I ran into a problem with square shape. Euclidean distance formula works but not as I expected. When one square touch the corner of other suqare - collision does not happened :(
Code Example:
Can you explain why and how to solve it, please? Thank you
The text was updated successfully, but these errors were encountered: