Jump to content

[Ninja Physics] "touching" not working with diagonal tiles


mBeierling
 Share

Recommended Posts

My workaround:

 

In "phyiscs/ninja/Circle.js" I change:

            if (dx === 1)            {                this.body.touching.left = true;            }            else if (dx === -1)            {                this.body.touching.right = true;            }            if (dy === 1)            {                this.body.touching.up = true;            }            else if (dy === -1)            {                this.body.touching.down = true;            }

To:

            if (dx === 1)            {                this.body.touching.left = true;            }            else if (dx === -1)            {                this.body.touching.right = true;            }            if (dy === 1)            {                this.body.touching.up = true;            }            else if ((dy <= -0.2 && (dx <= -0.2 || dx >= 0.2) ) || dy === -1)            {                this.body.touching.down = true;            }

After some tweaking, 0.2 as a limit for the normals works best for the tile shapes I use in my project.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...