-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collision does not work for rotated entities with updated origin #1201
Comments
Thanks for the bug report! Could you describe the error in a bit more detail? (Or provide a self-contained example?) |
Hi, sure the subset of my code which displays the reported behaviour follows: `
` |
my previous comment does not contain the inital lines, but they are quite obvious: |
If I skip the line |
Looks like something is going wrong when you set the width, origin, rotation, and hitbox in a specific order. I'll look into this further, but setting the origin after the dimensions, but before the other properties works around the bug: this.addComponent("2D, DOM, Color, Motion, Collision, SolidHitBox");
this.rotating = 0;
this.w = 30;
this.h = 30;
this.origin("center");
this.rotation = Crafty.math.randomNumber(0, 359);
this.x = Crafty.math.randomNumber(50, 450);
this.y = Crafty.math.randomNumber(50, 450); e: originally suggested setting the origin first, but that produces a slightly different bug. I think the root issue is that the collision hitbox isn't recalculated correctly when the origin is applied, and it's manifesting in a couple of different ways. |
thanks a lot. the workaround works fine :) |
I am using the following piece of code to check for collisions and to prevent them from moving, if needed.
It works well until I change the rotation origin (
this.origin("center")
) and rotate thethis
object. The erroneous behavior can be easily shown by adding theSolidHitBox
component to the respective entity.The text was updated successfully, but these errors were encountered: