Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

Make objects "tumble" or fall on lose condition - C#

$
0
0
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(); 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); } ![alt text][1] ![alt text][2] [1]: /storage/temp/25257-screen+shot+2014-04-15+at+5.06.30+pm.png [2]: /storage/temp/25258-screen+shot+2014-04-15+at+5.06.59+pm.png

Viewing all articles
Browse latest Browse all 1264

Trending Articles