Monday, June 29, 2015

Tutorial: Crosshairs

The cross hairs are actually one of the more simpler scripts. In fact its only 29 lines.

First thing we need some cross hairs, unfortunately the assets store doesn't have any free ones. So, google cross hairs, try and fine one that is in the .png format. This is because the .png format supports  transparency. This is important, because we want to be able to see through the cross hairs and not have surrounding colors take up screen space. You can usually tell if its transparent in the google search because if you click the image it will show a checkered white and grey background, secondly when you save the image to the desktop, you should just see the image, and no other background. If you do need to make your image transparent i would suggest the online image editor: http://www166.lunapic.com/editor/ 

Now import your image(ill leave that to you). Click the image and look in the Inspector tab. Under Texture Type select Texture. 


Tuesday, June 16, 2015

Tutorial: Grenade


Today will be a tutorial lesson, most of the code was made by me by recycling old code from previous experiments, and scripts, the rest was having to google snippets. I will add that this is not perfect, there is some tweaking that needs to be done. 

First we need a grenade model, you can get this one for free, it well done with good poly count and texture resolution: https://www.assetstore.unity3d.com/en/#!/content/8556

<NOTE: If this asset is removed try and find another for free, or if you wish spend the money, if you wish to forgo all this, just create a sphere scale it down to realistic level, and change the Mesh Renderer materials to a noticeable color. The create as a prefab.>

And now, we need a sound: http://www.freesfx.co.uk/soundeffects/explosions/?p=6
<NOTE: You will need an account, its free, and they have a good selection of various things.>
Download the Explosion, Small .mp3

Let me explain what we are doing. We will make two scripts, one to regulate explosion: the time it takes for the detonation to occur, the damage to be applied based on radius, then the clean up where we remove the prefab and the particle. The second script is for the spawning of the grenade, and the subsequent application of physics to make it move, as well as a GUI to keep track of quantity. This will all be done in C#: