Hi!
I’m making a simple mini golf game and I have issues with physics simulation. Basically in the game there is a ball which the player can hit and walls which are used to bounce the ball away, very much like in real mini golf. The ball gameobject has Dynamic collision object and the walls are built from tilesource and collision shapes for the walls are automatically generated by setting Collision image from tilesource Properties. Walls are built from 32x32px tiles and their collision object type is Kinematic.
Most of the time everything works as expected, but sometimes when the ball hits a wall it doesn’t bounce to correct direction; it actually bounces back to the direction it came from. And as I said, this only happens like 1/20 of hits.
My first thought was that there is something wrong with the way Defold simulates Dynamic collision objects so I changed the ball from Dynamic to Kinematic and wrote simple collision detection script to switch the direction of the ball as I desired, but quickly found out the same behavior continued. I also noticed that when the ball bounces to wrong direction the normal which I got from collision response was way of. So I rolled back to the original setup where the ball is Dynamic object.
I think this might have something to do with the automatically generated collision shapes of the walls. Because I have 32x32px tiles and all those tiles have separate collision shapes that means the walls are constructed from multiple small collision shapes. Maybe the ball is hitting a corner of a collision shape rather than straight side of it? Is this a bug or planned behavior?
If my assumption of whats happening is correct, is there a way around this problem? I really would like to use automatically generated collision shapes for the walls because it just makes my life so much easier if I have to build tens of different levels.