Flip game object physics problem re (DEF-1117) (FIXED)

I was just wondering if anyone came up with an ingenious way of working aroung the physics body rotation bug mentioned here:

I’m currently creating multiple collision objects (eg walk_left and walk_right) and enabling and disabling them when I flip a game object or animation. This is becoming a bit of a pain though as the project gets bigger.

I’ve seen some workarounds on the forum re sub game objects and this is ok providing the sprite flips but the collision object doesn’t need to. Not much good for a scorpion where the tail is stuck up on one side!

Cheers

2 Likes

We really should try and fix this along with physics scaling soon. I’ll see if we can bump the priority a bit and fix this before Christmas.

5 Likes

:hugs: This would be awesome thanks!

For anyone having problems with DEF-1117 and your left and right facing collisions are different (for example a scorpion enemy where the tail is at one side), here’s one solution that might help:

  1. Create a single ‘walk’ animation in a tilesource
  2. Attach a sprite to a game object using the tilesource
  3. Add two collision objects to the game object, one for left facing one for right

Then assuming your sprite is drawn facing right you can then use:

//Walk right
sprite.set_hflip('#sprite', false)
msg.post('.', 'play_animation', {id = hash('walk')})

msg.post('#collisionRight', 'enable')
msg.post('#collisionLeft', 'disable')
//Walk left
sprite.set_hflip('#sprite', true)
msg.post('.', 'play_animation', {id = hash('walk')})

msg.post('#collisionLeft', 'enable')
msg.post('#collisionRight', 'disable')

Physics flip added in 1.2.161

1 Like