I am developing demo project in that i want to stick sphere below another sphere…
Sample game is Here,…
Actually I am learning unity and do not have knowledge about all concepts so i am not getting way to implement this kind of arrangement of sphere , when i shoot new sphere. how do I get point between two sphere on collision.?
Till now i have generated sphere dinamically at perticular position and shooting functionality also done. Now i get stuck at this point…
Please suggest me some idea. Thanks In Advance For Your Support And Help…
If you watch the video, they are not sticking the bubbles to another bubble. They have a set of points which represent the potential positions of the bubbles. When a bubble hits another of a different color, they are sending it to the closest, empty position. By doing it this way, they maintain the order of the bubbles. If this is the functionality you want, I can describe a way to get it.
But to answer your question about getting the position between two bubbles, you could just use Collision.contats to find where it hit, or you can use the position of the two bubbles when they hit and calculate the position:
function OnCollision(collision : Collision)
{
var pointBetween = (collision.transform.position - transform.position);
pointBetween = transform.position + pointBetween * (0.5 - gap);
}
Gap is the fraction amount away from the center (so the bubbles are spaced). If gap == 0, then this code will find the spot half way between the two bubbles. There are other ways to calculate this position, but as I mentioned above, it looks like they are sending the bubble to the nearest empty place on the board.