Skip to content
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

Scale X=-1 breaks collision physics #2688

Closed
ufukbakan opened this issue Jul 9, 2023 · 4 comments · Fixed by #2694
Closed

Scale X=-1 breaks collision physics #2688

ufukbakan opened this issue Jul 9, 2023 · 4 comments · Fixed by #2694
Labels
bug This issue describes undesirable, incorrect, or unexpected behavior

Comments

@ufukbakan
Copy link

After setting scale.x to -1 my character goes through other colliders, can we fix this

@eonarheim
Copy link
Member

@ufukbakan Thanks for the issue! This is definitely unexpected, my guess is there are some flipped normals in the collider geometry when this happens causing the errant behavior.

Are you using scale.x = -1 to flip the graphics? If so, one workaround might be to use Graphic.flipHorizontal https://excaliburjs.com/docs/api/edge/classes/Graphic.html#flipHorizontal

@eonarheim eonarheim added the bug This issue describes undesirable, incorrect, or unexpected behavior label Jul 10, 2023
@ufukbakan
Copy link
Author

@ufukbakan Thanks for the issue! This is definitely unexpected, my guess is there are some flipped normals in the collider geometry when this happens causing the errant behavior.

Are you using scale.x = -1 to flip the graphics? If so, one workaround might be to use Graphic.flipHorizontal https://excaliburjs.com/docs/api/edge/classes/Graphic.html#flipHorizontal

I was scaling actor itself not the graphics (because i didnt want to loop all graphics and flip each of them) but it broke the physics so i had to loop each graphic animation to flip them

@eonarheim
Copy link
Member

@ufukbakan Would a new feature on the graphics component to flip all the graphics associated with the actor during drawing be useful?

Something like

const actor = new ex.Actor({...});

// Flips during drawing but doesn't 
actor.graphics.flipHorizontal = true;
actor.graphics.flipVertical = true;

@ufukbakan
Copy link
Author

@ufukbakan Would a new feature on the graphics component to flip all the graphics associated with the actor during drawing be useful?

Something like

const actor = new ex.Actor({...});

// Flips during drawing but doesn't 
actor.graphics.flipHorizontal = true;
actor.graphics.flipVertical = true;

Yes, i think it will be, so we dont have to define runLeft, runRight, jumpLeft, jumpRight, idleLeft, idleRight, attackLeft, attackRight... Just we will able to define run, jump, idle attack graphics and flip graphics if facing left

eonarheim added a commit that referenced this issue Jul 15, 2023
…2694)

Closes #2688 

## Changes:

- Adds new convenience properties on the `ex.GraphicsComponent` to flip all the graphics on an `ex.Actor`
    * `ex.Actor.graphics.flipHorizontal` - Flips all the graphics horizontally
    * `ex.Actor.graphics.flipVertical` - Flips all the graphics vertically
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue describes undesirable, incorrect, or unexpected behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants