Jump to content

Physics body slightly off center? Circular body a factor?


GreatBigBore
 Share

Recommended Posts

I had this problem a while back, and fixed it, but I don't remember how I fixed it, or whether I even understood what I had done to fix it. I have circular physics bodies. I use setSize() followed by setCircle() -- I'm not sure whether the setSize() is necessary; it's possible I'm doing it for superstitious reasons relating to the last time I had this problem. I have collideWorldBounds turned on, but my sprites can go about 15px off the bottom and right of the world, and they stop about 15px short of the top and left of the world, like their centers are off. I can see, when I turn on game.debug.body and game.debug.spriteBounds, that everything looks perfect: square sprite bounds and round body bounds, all perfectly centered. As I say, I had it fixed, but I don't remember what I did, and so far I haven't figured out what I did to break it again.

Using arcade physics. Also, body.syncBounds = true, although I tried it false too, out of superstitious desperation. Anchors set to 0.5, 0.5. Thoughts?

Link to comment
Share on other sites

In case anyone else runs into something similar: I'm not entirely sure of this, because now it's working fine again, and I'm too busy curing cancer to bother with trying to re-break it. But I think it has something to do with using body.position instead of body.center when moving my guys around. Maybe I'm just asking for trouble by moving the body around manually, but I had to in order to get natural-looking motion, to get them to accelerate and decelerate smoothly while tracking targets. Anyway, body.center, not body.position. That might not be it after all, but it's my best guess.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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