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

Disable colliders before copying tiles #50

Open
OndrejNepozitek opened this issue Apr 27, 2020 · 0 comments
Open

Disable colliders before copying tiles #50

OndrejNepozitek opened this issue Apr 27, 2020 · 0 comments

Comments

@OndrejNepozitek
Copy link
Owner

It seems that if colliders are enabled on shared tilemaps when we copy individual room templates, Unity tries to incrementally rebuild them to update their shape. When working with bigger levels, this can cause noticeable lag (up to 10 seconds on levels with hundreds of rooms, 1-2 seconds on medium sized levels).

Based on some quick tests, it seems like it is better to first disable all colliders and only enable them after all tiles are copied to the final level. The difference might not be noticeable on small levels, but it went from 10 seconds to cca 2 seconds iirc. We need to do some additional performance tests.

There are at least 2 possible approaches to handle this:

  1. We can split tilemap layers initialization into 2 stages. In the first stage, we would create tilemaps without colliders and in the second stage, we would only add the colliders. The second stage would be called only after all the tiles were copied. The problem of this approach is that it makes it harder for uses to implement their own tilemap initialization logic because they would need to split the logic.
  2. Before copying tiles, we can go through all the colliders of individual tilemap layers, mark which ones were enabled and then disable them. We would then copy all the tiles and after that we would enable all the collider that were disabled in the previous step. The advantage of this approach is that it is transparent for users. We just have to make sure that there are no problems with disabling and then enabling colliders.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant