- Home /
how do I edit enemy stats
So I am new to unity, I searched the Forums and haven't found an answer to my question. Basically, I want to have different sized monsters with different healths, attack, etc. The closest thing I could find applies to all of a type of monster, not each monster individually. Do I have to write a different script for each one, or is there something else I can do?
Thanks for the advice, however, the monster I am used is a prefab, from the Skeleton asset pack. I don't understand how to properly edit these monsters.
Answer by Klarax · Feb 25, 2014 at 04:31 PM
Thanks, this might help, but can I make the variable applicable to a height? So that I just make a monster a certain height and the variables are applied automatically?
Answer by Regalith · Feb 25, 2014 at 05:32 PM
Just create a prefab for each monster, and set the variables you want to set yourself to public variables
in javascript its
public var variable: variableType;
in c# its
public variableType variable;
once you set them to public, when you click on the object in your scene, you can edit the variables in the Inspector
Answer by gwubgwub · Feb 25, 2014 at 06:15 PM
depending on how random you want the monster sizes to be, if you want a hand full of different sized monsters you could make an array would hold your different sized monsters as prefabs and load them in randomly. For this have a look at http://unity3d.com/learn/tutorials/modules/beginner/scripting/arrays and http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/infinite-runner
With the different health you could make a int that would generate a random number (health) when called on.
int health = (random.range(50,100));
maybe something like this I have not tested it but hopefully you can get an idea.
Your answer
Follow this Question
Related Questions
Show only selected enemy's health bar 1 Answer
Weapon and enemy health 0 Answers
Melee Damage script by collision 2 Answers
I use this script, but the enemy lose health if i don´t target him. 1 Answer
Attack,Health and enemy health. 1 Answer