O'Reilly logo

Getting Started with Unity by Patrick Felicia

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

Creating a gun

Before creating the necessary script for the bullet and collision detection, we will add a crosshair in the middle of the screen to improve the player's accuracy.

  1. Create a new GUI texture, and rename it GUITexture_crossHair.
  2. Change its position to (x=0.5, y=0.5, z=0), so that it is displayed in the middle of the screen.
  3. Drag-and-drop the texture labeled Crosshair by selecting Assets | chapter4 | chapter4_pack to the GUITexture component of this object, as illustrated in the following screenshot:
    Creating a gun
  4. This should display the crosshair in the middle of the screen in the game view.
  5. In the GUITexture component of the object GUITexture_croshair ...

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