Soldier&Raycasting — UnityGameDebut

Toon Soldier Character & Rays— Episode #05

J3
KidsTronics
4 min readMar 4, 2018

--

I’ve learned a lot doing a game in Unity and the most important part is the fun I have had. So, I invite you to do the same. Follow this series and you’ll get a running game:)

In the previous tutorial, we get a crosshair following the mouse position.

Now let’s get our character in the scene: The Enemy.

Step #01 — Import Toon Soldier Demo pack: In Unity, app Go to 1 ) Asset Store, click on Toggle Down Manager Butt, 2) filter by toon and 3 & 4) click Import two time; return to the Scene view; Delete mesh_infantry previously imported with .fbx; in the next procedure we will import it again;

POLYGON BLACKSMITH — Toon Soldiers Demo

Step #02 —Under ToonSoldier_demo > models folder drag n’ drop ToonSoldier_demo in the scene. Use w and e keys to positioning it so that you can see from the sniper perspective only the enemy’s arm. I chose the middle and last tower to hide them, but for now, drag only one to the scene;

Step #03–Under 1) Toon_Soldier > Animation folder choose the idle animation and 2) drag n’ drop it right into ToonSoldier_demo_1 (renamed); 3) Now double click the animation icon just created and open Animator tab; There you can see the 5) flow diagrams created automatically for you; click on Animator tag to activate and organize it;

Step #04 —Let’s try out our setup…select Scene tab; 1) deselect Maximize On Play button 2) click play the animation and 3) see on the background the enemy idle animation running;

Step #05 — As the hiding and showing of the enemy will be controlled by SoldierController script, let’s make a parent folder named Soldier;

Click on 1) Create > Create Empty gameObject, rename to Soldier; 2) make a hierarchy Soldier>ToonSoldier_demo_1 for a reusable purpose; drag it to the top, then drag it into the folder Soldier;

Step #06 — Go to 1) Assets > Scripts folder, 2) right mouse click it, Create > C# Script name it Soldier; 3) drag n’ drop to Soldier gameObject so that this is 4) a tight knot for Soldier script;

Step #07 — Now import iTween lib pack: In Unity, app Go to 1 ) Asset Store, click on Toggle Down Manager Butt, 2) filter by itween and 3 & 4) click Import two time; iTween is a simple, powerful and easy to use animation system for Unity; return to the Scene view;

PIXELPLACEMENT — iTween

Step #07 — Code Soldier.cs like this:

(Soldier.cs)

Step #081) Run the game and now the soldier 2) moved to the left and has stayed there; 3) adjust the position of the soldier by dragging blue arrow (when the game is not running…note: it works while running but doesn’t save status); in the next post we will make transitions back to idle…

There you have it! In the next post, we will add another Enemy and refactoring the code. Stay With Me :)

Thanks, everyone! Bye!

GitHub Repo

# 0 #1 #2 #3 #4 #5 #6 #7 #8 #9 #10

References & Credits

Making a Game with Unity (1–10) : Basics by Jayanam

http://wiki.unity3d.com/index.php?title=Singleton

--

--

J3
KidsTronics

😎 Gilberto Oliveira Jr | 🖥️ Computer Engineer | 🐍 Python | 🧩 C | 💎 Rails | 🤖 AI & IoT | ✍️