O'Reilly logo

HoloLens Beginner’s Guide by Jason Odom

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

ThrowBall.cs

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required