- Home /
how do u make diffrent chacters and give them commands 2 do things
i was wondering how u make cpu,s and give them commands also how to give ur character have health and also give the cpus health so i can get an army and fight against other armys
i would so appreciate if anyone could help ive had this question 4ever
You've asked a lot of questions there. I'm assu$$anonymous$$g you mean "NPCs" when you say "cpus". You haven't even said what type of game you're hoping to make (FPS/TPS/RTS/turn-based/etc). UnityAnswers is generally for help with specific problems. $$anonymous$$any of your questions may already have been answered (for example, see http://answers.unity3d.com/questions/8348/how-to-create-an-npc-enemy-which-can-take-damage-and-be-killed-when-its-energy-or)
You should read up on what you can and have a go yourself first. Then you can ask for help once you get stuck on specific problems.
just mail me i have what you want in my $$anonymous$$d, i created i $$anonymous$$m game, that you have your $$anonymous$$m fire, shoot, and fight with you with only CPU
Answer by Dok101 · Dec 28, 2013 at 09:28 PM
Well for CPUs you will obviously need to have an AI (Artificial Intelligence). This is possible to create but very hard. Im not sure what type of army you are planning to make (as in whether its swordfighters, gunfighters etc.) but there are many AIs on the asset store that are specifically for shooting CPUs. You can use these in your game until you become more experienced and know more about Unity.
To give your character health that can be taken away when hit just make a variable called damage, another called health and another called CPU health. Use Physics.Raycast to find out if when the player attacks he is facing the enemy and within a certain range. If those conditions are true then CPU health = CPU health - damage;
Then you could also have in the update function damage = Random.range (10,20); which means that the CPU health will be going down by a random number between 10 and 20. Or you could have it is as a set number and make it go up if you buy a better sword. For the CPU you could have a Physics.Raycast again and every 5 seconds if the CPU is within a certain range of the player then health = health - damage; Obviously then you can make a boolean called shield and when a button is pressed shield = true; so if shield = true damage = 0; and then do the same for the AI
Hope this brief explanation helped
Just ask if you need any more help
Answer by DayyanSisson · Oct 05, 2011 at 10:12 PM
You should learn how to use Unity and scripting first before you jump right into it. Look at this question. It will definitely help.