wiserim / phaser-raycaster

Raycasting plugin for Phaser 3. Documentation:

Home Page:https://wiserim.github.io/phaser-raycaster/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tilemaps mapping doesn't work properly on Phaser 3.50

mageowl opened this issue · comments

Describe the bug
Tilemap raycasting no longer works in Phaser 3.52.0.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'https://codepen.io/wiserim/pen/pojNmRK'
  2. Click on 'Settings'
  3. Change "https://cdnjs.cloudflare.com/ajax/libs/phaser/3.22.0/phaser.min.js" to "https://cdnjs.cloudflare.com/ajax/libs/phaser/3.52.0/phaser.min.js" and "https://cdn.jsdelivr.net/npm/phaser-raycaster@0.7.3/dist/phaser-raycaster.min.js" to "https://cdn.jsdelivr.net/npm/phaser-raycaster@0.9.1/dist/phaser-raycaster.min.js"
  4. Close settings and re-run project.
  5. See error

Expected behavior
The shadows will only show in the top left corner.

Screenshots
Phaser 3.22.x
Screen Shot 2021-02-10 at 6 49 57 PM
Phaser 3.52.x
Screen Shot 2021-02-10 at 6 47 57 PM

Desktop:

  • OS: MacOS 11.2.1
  • Browser Chrome
  • Version 0.9.1 (Phaser 3.52.0)

Thank you for informing me about this bug.
I'll check it and try to fix it this weekend.

Edit:
The bug is the result of tilemaps revamp in Phaser 3.50.

I've been trying to implement my own version of this, and I have some questions:

  • Where do cast the rays? To every tracked point? Every 10 degrees?
  • How do you generate the fills?
  • How do you keep rays from passing through corners?

Version 0.9.2 has been released.
It fixes the problem with mapping tilemaps in Phaser 3.50.0 (for orthogonal tilemaps only).

I've been trying to implement my own version of this, and I have some questions:

* Where do cast the rays? To every tracked point? Every 10 degrees?

* How do you generate the fills?

* How do you keep rays from passing through corners?

I. Phaser-raycaster is casting rays to game object's corners (mapped in advance to save processing time) plus corners of game area.
II. I draw ray caster's field of view by drawing polygon made out of intersection points between ray caster's ray and game objects (they're sorted by angle they were casted). You can find examples on codepen: link.
III. When ray hit a corner it casts two additional rays at sligthly different angles, to hit whatever is behind the corner.

If you want to make your own ray caster there's some useful links:

  • Phaser.Geom.Intersects documentation - set of methods for checking intersections between geometric objects in Phaser 3: link,
  • "“VVVVVV” HTML5 prototype powered by Phaser meets light and dark with ray casting and the result is astonishing" by Emanuele Feronato: link,
  • "SIGHT & LIGHT how to create 2D visibility/shadow effects for your game" by Nicky Case: link,
  • "Ray casting 2D" by Daniel Shiffman: link,
  • "2d Visibility" by Amit Patel: link.