Jump to content

p2 bodies aren't aligned correctly from Tilemap


seiyria
 Share

Recommended Posts

When I load my entities from a tilemap, some of them are misaligned, for example:

1b07d1f722.png

 (magenta and teal are off a little bit)

 

so I shift these particular objects with x+16, y-4 and I get: 

7f357f9dbe.png

(both red)

 

now they're both aligned correctly.

 

My question is, is there some setting I have to change when creating objects? Having these adjustments, and then having to rotate some bodies, is more frustrating than it should be! Nothing seems to line up like it should.

Link to comment
Share on other sites

Looks like something to do with the bodies' anchors. The first image appears to have the anchor in the center of each body.

 

This came to mind: http://examples.phaser.io/_site/view_full.html?d=tilemaps&f=create+from+objects.js&t=create%20from%20objects

Some of the signs and boxes have a weird offset too.

 

 

So it turns out that when a game object is enabled for P2 physics it has its anchor x/y set to 0.5.

Edited by Arcanorum
Link to comment
Share on other sites

Hm. I wonder what to do about that then? Should the anchor be set to 0,0? Or maybe I should just make sprites for each rotation, haha. I originally wanted to save on spritesheet usage and just rotate my sprites, which worked for Arcade. Just gave it a roll yesterday with p2 and it does not seem to like that very much.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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