Radem Posted August 30, 2017 Share Posted August 30, 2017 I am using arcade physics in my game with gravity and tileset. Character can crouch. When it crouches, animation is run and body size is adjusted by method setSize(), problem is, that sometimes character falls down through the tile that it is supposed to collide with. I don't understand, there must be some secret behind that setsize method, because if I remove it, character collides normally when crouches. Link to comment Share on other sites More sharing options...
samme Posted August 30, 2017 Share Posted August 30, 2017 If you enlarge the body so that its bottom edge substantially penetrates the floor, it will fall through, the same as if you had moved the body downward by the same amount. Link to comment Share on other sites More sharing options...
Radem Posted August 30, 2017 Author Share Posted August 30, 2017 I don't enlarge the body, but I make it smaller and the new bounds of the body doesn't exceed the previous ones. However, I was blind while debugging. Now I know that it only happens when the character is looking left (is scaled by -1). It doesn't make any sense to me, for the scale is only set to x coordinate, while my problem relates to the vertical direction. It brings another question: If I want to resize the sprite's body, can I somehow turn the sprite using scale.x property? (without causing the sprite to behave that wrong way). Or do I have to add to the spritesheet flipped images of every frame? That would be really disappointing. Thx for response. Link to comment Share on other sites More sharing options...
samme Posted August 30, 2017 Share Posted August 30, 2017 Are you using game.debug.body()? Link to comment Share on other sites More sharing options...
Radem Posted August 31, 2017 Author Share Posted August 31, 2017 Ok, solved. I didn't know that when I set scale.x to -1 that width property becomes negative value as well. That leaded into passing negative numbers to setSize() in my method, causing the body to bug. Thx samme for these debug methods, they are very useful and can save some time, perhaps I need to check the documentation more. Link to comment Share on other sites More sharing options...
Recommended Posts