With the GameBall selected, click on AddComponent | NewScript and create the ThrowBall.cs class. Grab this file from the downloads. We will not put the whole thing here, but we will go over the important area of the script:
Here, in our Update() function--remember that it's called every frame--ApplicationManager.Instance.ThrowBall is checked. If that bool is true, this code is executed:
- throwDirection is a variable set by the current forward vector of the camera or your position. Simply put, the angle you are pointing to determines the angle the ball will be thrown in.
- throwForce is a variable set by our BounceObjectToPoints ...