- Home /
Make objects "tumble" or fall on lose condition - C#
In the block breaker game that I'm currently creating, I'm trying to figure out how to get a lose condition where if the player loses, the blocks that are left on the board will have gravity added to them and will fall down. How can I make this possible? I'll post my code for the "Tumble down feature" and then I'll post screen shots of what the board looks like at the start and then on the lose condition.
public void GridTumble() {
for (int x = 0; x<10; x++) { //Goes through each row
for(int y = 0; y<10; y++) { //Goes through each colum
//Apply Gravity
grid[x,y].gameObject.AddComponent<Rigidbody>();
grid[x,y].gameObject.rigidbody.useGravity = true;
}
}
}
IEnumerator waitForLose() {
gameBoard.GridTumble(); //This accesses the gameBoard class and calls the tumble function
yield return new WaitForSeconds(10);
gameBoard.DestroyGrid(); //Destroys the grid
activateScreens(menuScreen.Lose);
}
screen shot 2014-04-15 at 5.06.30 pm.png
(68.6 kB)
screen shot 2014-04-15 at 5.06.59 pm.png
(22.9 kB)
Comment
Your answer
Follow this Question
Related Questions
Shifting blocks to the right to remove empty spaces - C# 0 Answers
Applying force to my object has no effect. 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers