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

Try to fix Hexagon(RowEven/RowOdd/ColumnEven/ColumnOdd) collider bugs. #39

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

darkautism
Copy link

Fix Hexagon colider bugs

image
image

@darkautism
Copy link
Author

Need this patch: mapeditor/rs-tiled#313

@darkautism
Copy link
Author

Do not fix #41 .
If you want to flip the Y axis, do it independently.

@darkautism
Copy link
Author

Also fix IsoCoordSystem::Diamond
image
image

@adrien-bon
Copy link
Owner

Hi!

Thanks for the PR and the example to reproduce the issue.
Actually, it seems we have an issue with colliders from tiles for hex and iso maps.
We only tested colliders from objects, not from tiles.
Now I understand your issue.

Regarding your code:

  • we may not have to depend upon hexside_length. Have a look to https://github.com/adrien-bon/bevy_ecs_tiled/blob/main/src/loader.rs#L864. I'm not good at math (and I did not check yours thoroughly) but if we can it would be nice to unify how we handle objects (previous link) and tiles so we only have one "math" function for both
  • you only applied your fix for "finite" maps. I believe "infinite" maps are a bit broken but if you have time it would be nice if you could try to apply your fix for them too, it may actually improve things
  • the debug_render is a nice addition but it should go in the debug plugin
  • not sure what's going on with CI, I'll have a look when I have more time

@darkautism
Copy link
Author

  • I'm afraid not, these arithmetic are not even multiplied by the number of cells, RowOdd even uses object_x directly, this does not work
  • I have no way to fix the infinite map, it will crash in the tilemap crate.
  • Moved

@adrien-bon
Copy link
Owner

I pushed an update to your PR in order to re-use the example assets from the repo instead of yours.
Unfortunately, it seems your fix does not work with them.

  • hex map /stagger index = even / stagger axis = X => seems like colliders X position is messed up, colliders should be above the mountains
    image
  • hex map / stagger index = odd / stagger axis = X => seems like colliders X position is messed up, colliders should be above the mountains
    image
  • diamond isometric map => seems like colliders X and Y positions are messed up, colliders should be above the trees
    image

FYI I just updated both hex_map and isometric_map examples.
You just have to run them with either avian or rapier feature enable:

cargo run --example isometric_map --features=avian
cargo run --example hex_map --features=avian

Could you please have a look and fix the maths so these examples work ?

@darkautism
Copy link
Author

This patch fix the tile collider not object collider.
I think this is helpful: https://bevyengine.org/examples/animation/custom-skinned-mesh/

@adrien-bon
Copy link
Owner

This patch fix the tile collider not object collider.

Yes I know what you want to fix here.
What I am saying is that when I add tile colliders to the existing examples in the repo your fix does not work.
For instance, in the 1st screenshot,tile colliders should be on the mountain. Not to their left.

I think this is helpful: https://bevyengine.org/examples/animation/custom-skinned-mesh/

Not sure what do you mean ?

@darkautism
Copy link
Author

According to #32, these object deformers not only have incorrect positions, they also need to be deformed.

@adrien-bon
Copy link
Owner

adrien-bon commented Oct 25, 2024

#32 is another issue that applies only to isometric maps, where colliders have the proper position (at least object colliders) but not the proper shape.

Here we are trying to fix tile colliders not having a correct position, both for hexagonal and isometric maps.
As I said, I think the maths you added do not fix the tile collider position issue. Please, have a look to the screenshot I posted (there is an issue with hexagonal maps too, not only isometric).

If we reach in this PR a status where tile colliders have the correct position but not the proper shape for isometric maps I'll consider it done and that the shape issue will be fixed in #32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants