Make sure that the 2D physics objects that are colliding are actually moving with their own velocity. If all you’re doing is repositioning them via the Transform component then you’re simply forcing overlaps and the physics system will do its best to resolve the overlaps. In other words, it’s just causing problems that the physics system is trying to solve but nothing is actually ‘moving’ thus there’s no bouncing etc.
I’m not touching location (or forces) of the balls that player is supposed to push after initial layout. Only object that gets force applied is player. Balls do bounce properly if angle is big enough but smaller angles between dirction of movement and wall balls do tend to slide along the edge for some reason.
Player ship is controlled with: A = counterclockwise, D = clockwise, W = forward. Only blue ball currently does have a proper physics material and rigidbody.
If that blue ball is pushed in small angle against wall it will glide. Also it’s very easy to make that ball stuck in a corner without way to get out it there.
Originally my idea was to have real clip + mirror on each edges but found out that’s relatively hard to achieve, specially with similar physics requirements. I mean that if ship is half way over left hand edge, half of the ship is already visible on right hand side.
Hm I have absoluteley no experience with that kind of thing but what I would try next ist setting the friction of the wall a bit higher. My guess would be, that if the angle is too small, the physics calculates that the ball has to slide the wall, that means, all of the force is directed along the wall and nothing is there to bounce. If you think in real world terms, if you have a wall out of perfect ice then it would be the same behaviour.
I’ve tried pretty much everything. I updated my prototype to have different bounciness and frictions to ball and walls. Apparently small angle will eventually end up with gliding along the edge - I really want to avoid that, after all this is supposed to be more arcade game than physics simulation.
So I’m open for all suggestions - if everything else fails, I can always manually do the physics math.
If you’re producing large tangental forces (along the wall) as oppose to small forces ‘into’ the wall then it’s bound to ‘slide’ as the energy has to go somewhere. I’m not sure if it’ll help but you can set friction to values >1 to produce non-realistic results.
I’m still not clear on exactly what you want but have you considered adding a force to repel the ball from the walls when in contact? This’ll force them out of corners or against edges.
Large tangential forces sounds something that I’m most probably experiencing. Have to play around with frictions a bit more, and if that fails I probably have to add manually force on contact, which isn’t bad option either.
Box2D has a velocity threshold (in 2D physics settings) which I converted from a compile-time constant to something you can change at runtime. Any collisions with a relative linear velocity below this threshold will be treated as inelastic.