asked 138k views
0 votes
Unity C# Game, I'm trying to make a game where is GameObject Player (Ball) and I shoot it to "Hole" (in this case hole). Whenever I hit a hole with my ball, ball destroys and spawns back to the spawn point and I can shoot again. This function have to happen 5 times and game would be over. How do I do that? I know some people have responded my questions earlier but those responds were not helpful. Code have to be explained, thank you already!

1 Answer

3 votes

To achieve the desired functionality in your Unity C# game, you can follow these steps

Step 1: Set up the scene

Create a GameObject for the player ball and position it at the spawn point.

Create a GameObject for the hole.

Step 2: Create variables

Declare a variable to keep track of the number of times the ball has hit the hole.

Declare a variable to store the maximum number of hits before the game is over (in this case, 5).

Here's an example of how you can declare these variables at the top of your script

private int hits = 0;

private int maxHits = 5;

answered
User Theatlasroom
by
7.9k points
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.