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

Tile custom colliders on isometric map causes error on load #391

Closed
mattjennings opened this issue Jul 22, 2022 · 3 comments · Fixed by #477 · May be fixed by #392
Closed

Tile custom colliders on isometric map causes error on load #391

mattjennings opened this issue Jul 22, 2022 · 3 comments · Fixed by #477 · May be fixed by #392
Labels

Comments

@mattjennings
Copy link
Collaborator

I'm not sure if tile custom colliders are officially supported, but an error is thrown when trying to use them.

Log.ts:173 [Error] :  Error loading resources, things may not behave properly TypeError: Cannot read properties of undefined (reading 'split')
    at B.getCollidersForGid (tiled-map-resource.ts:513:35)
    at B._createTileMap (tiled-map-resource.ts:664:45)
    at tiled-map-resource.ts:412:18

It seems the polygon data structure is not what it expects:

CleanShot 2022-07-21 at 23 21 28@2x

(inspecting polygon.polygon)

Steps to Reproduce

See repro: https://github.com/mattjennings/excalibur-iso-tiled-collider-bug

npm install
npm run dev

I've added both an isometric and orthogonal tilemap that uses the same tileset. When loading the isometric, the above error occurs on load. However, the orthogonal map does not cause the error, so the polygon data must be different in isometric vs orthogonal?

Expected Result

Isometric custom tile colliders to be loaded

Actual Result

An error is thrown

Environment

  • browsers and versions: Chrome 103
  • operating system: macOS 12.4
  • Tiled version: 1.9.0
  • Excalibur versions: 0.27.0
  • Tiled plugin versions: 0.27.0
  • (anything else that may be relevant)

Current Workaround

None

@eonarheim
Copy link
Member

@mattjennings Thanks for the bug!

I bet this a bug in the TSX vs TSJ parsing. The XML version stores the points in an odd string representation that needs parsing. It appears the TSJ is far more convenient. Should be a quick fix to support the TSJ hopefully🤞

I've had a few of these types of bugs, I might spend some after fixing this to refactor the tiled parsing to be more robust.

@eonarheim eonarheim added the bug label Jul 22, 2022
@eonarheim
Copy link
Member

I have something that mostly works, needs more testing. Vite really resists npm link!

image

@mattjennings
Copy link
Collaborator Author

@eonarheim I spent some time trying to get @excaliburjs/plugin-tiled propertly symlinking with vite myself and the following vite.config.js is what worked for me:

import { defineConfig } from 'vite'

export default defineConfig({
  optimizeDeps: {    
    force: true, // vite 3.0.0 feature, busts node_modules prebundle cache
  },
  resolve: {
    preserveSymlinks: true,
    dedupe: ['excalibur']
  }
})

However I use pnpm to both install and link my packages (pnpm link path/to/excalibur-tiled), so possibly there's some differences there with npm link, but this is what finally made it work reliably for me

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