Crosshair&Coding — UnityGameDebut
Starting the Code— Episode #04
Thanks to our efforts in the previous post here’s finally the code hour!
Step #01 — Import crosshair pack: In Unity, app Go to 1 ) Asset Store, click on Toggle Down Manager Butt, 2) filter by a simple cross and 3 & 4)click Import two times; return to the Scene view;
Simple Modern Crosshairs: Pack 1 — Icons
Step #02 — Let’s use the image UI System. 1) Create an Image by right mouse button the Explorer and UI > Image; this will automatically create a 2) Canvas object, which is the parent for all images and 3) a canvas will appear on the screen;
Step #03 — On Explorer 1) Select the Image; 2) rename it to Crosshair; now select Assets > SMC Pack > Pack folder and 3) drag 3.psd to Source Image slot, 4) click on Set Native Size Button and there you go a 5) crosshair right in the middle of the screen;
Step #04 — Now the fun begins, On Explorer 1) under Assets folder 2) Create > Folder type Scripts,3) right mouse click Create > C# Script, name it Crosshair, 4) Menu Edit > Preferences confirms under 5) External Tools tab if 6) Visual Studio 2017 Communities Edition is selected;
Step #05 — Double click Crosshair.cs; Visual Studio 2017 opens up, and Here is the code:
Step #06— Click Save All on Visual Studio 2017 and …
Step #07 — In Explorer 1) drag n’ drop the Crosshair.cs to the Crosshair image 2) to append it and you’re done!
Step #07 — Run the game!
tadaaaaaa...! the crosshair start to follow the cursor!
In the next post, we will introduce the Enemy to the scene :)
See you all soon! Thanks, n’ Bye!