-1

I have this classic situation of a pinball game

All objects are physicsBody with rights collision masks and so on.. they collide perfectly. The problem is that they only work when they are static...If I try to rotate a paddle on its anchorpoint, there is no collision with the ball and the ball falls down, passing through the paddle.

I thought it was a problem of speed but I think that during the rotation the physicsBody simply doesn't work.

Do you have suggestions?

Thank you so much.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • Post the code you use to rotate the bodies. Both ball and paddle need to be dynamic. If both are static, they will not collide. – CodeSmile May 11 '14 at 12:54
  • I use something like that SKAction *rotate = [SKAction rotateToAngle:-0.6 duration:0.02]; [padright runAction:rotate]; – Christian Ghelardoni May 11 '14 at 13:06
  • the ball is dynamic and the paddle is static....they collide...but the problem happens when I rotate the paddle... ... For example: the ball is on the paddle, i touch the button to rotate the paddle to throw the ball to the air...at this moment the collision doesn't work – Christian Ghelardoni May 11 '14 at 14:06

1 Answers1

0

That's exactly the problem you get when rotating a static body, it's not going to act physically correct.

For example static bodies have no force, no velocity - if you move or rotate it, it will just be there at the new position and new rotation without pushing any dynamic bodies around. Only if a dynamic body now happens to be intersecting with the static body will the physics engine try to resolve the collision, usually in a brute-force manner (aka "get me outta here").

Therefore the paddle has to be dynamic if you want it to move, accelerate and spin the ball. Both paddle and ball may need to have continuous collision detection enabled as to not lose any precision in the paddle motion applied to the ball, and vice versa.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • To accomplish that I need to create a joint between the base and the paddle ? beacuse if I set the paddle as dynamic (also with affectedtogravity setted to NO) when the ball hit it, it flows around the screen – Christian Ghelardoni May 11 '14 at 16:41
  • 1
    yup, you need a pin joint with proper limits and connected to a static body. – CodeSmile May 11 '14 at 19:32