- Home /
suggested rigidbody2d types to use? blocks and balls
I have a 2D breakout-like game with blocks and a series of balls. I want the balls to collide with and bounce off of the boundaries, the blocks, and any other fixed or moving obstacles in the playing area. BUT, I prefer that the balls do not collide with each other, I want them to pass through each other.
Using all Dynamic rigidbody2d for balls and blocks, with Static for boundaries works as expected but the balls collide with each other.
Can you suggest settings for the Body Type (and/or Simulated) field for the Rigidbody 2D components for the blocks, balls, and boundaries so that the balls do not collide with each other??
Answer by MelvMay · Feb 20, 2017 at 10:06 AM
The blocks should also be static unless you intend for them to move; this will also improve performance.
The balls should be dynamic if they are moving via forces or you directly setting the velocity of them. If you are controlling the position of them yourself by modifying the Transform.position and Transform.rotation them you should use a Kinematic body-type. If using Kinematic then you should also turn on the Rigidbody2D.useFullKinematicContacts which gives you full collision contact callbacks when Kinematic touches any body-type. Otherwise, Kinematic only contacts Dynamic.
If you don't want balls to collide with each other then place them on the samer layer and go into the 2D physics settings, specifically the layer collision matrix and uncheck the box which controls the ball layer colliding with itself.
Note: Ensure you use the 2D physics settings and not the 3D physics settings, both of which have their own layer collision matrix.
Tried the layers suggestion and it worked!!
I didn't know anything about layers before, but found this layers collision picture (>1000 words), and it took me 1 $$anonymous$$ute to implement $$anonymous$$elv$$anonymous$$ay's suggestion!! $$anonymous$$any thanks, $$anonymous$$elv$$anonymous$$ay!!
Your answer
Follow this Question
Related Questions
Maintaining the trajectory of a ball when manipulating its velocity in a Breakout/Arkanoid clone 1 Answer
Setting the angle of a ball in a Breakout game 2 Answers
Bat and ball game - is there a way one can store the ball's last collision? 1 Answer
Help with respawning paddle and ball in Breakout 3D,Respawning a paddle and ball in Breakout game 0 Answers
Change direction of ball based on where it hits paddle -- 3d breakout game 0 Answers