Time for action – adding a goal zone
Perform the following steps to add a goal zone and complete our game:
Extend your main platform by adding other platforms that create a straight path.
Reposition your marble to start on the leftmost platform so that it can be rolled to the rightmost one.
Exact positioning isn't necessary; just make sure your marble can roll from one platform to another.
Add in at least one small wall for your marble to jump over in order to reach the end.
Your finished product should look somewhat similar to the following screenshot:
Next, we'll create the goal object by performing the following steps:
Create a new cube with default scale and put it somewhere on the other side of the wall.
We will want to know when our marble hits the goal, so we'll write a code to access the collider property of this goal object.
Create a new C# script called
GoalBox
, attach it to your new cube, and open it for editing.Just like the rigidbody component, the collider component also grants the...