2
Creating an instance of a class
Post Body
Sorry. Haven't coded for over a year. So some super stupid questions are inbound.
I have a class. It defines the attributes of a character. And looks like this:
public class CombatantDefinition : MonoBehaviour
{
public string fightersName;
public Vector2Int damageRange;
public int health;
public int dexterity;
public int baseAttackSpeed;
public int currentAttackSpeedValue;
public bool isAlive = true;
public Weapon equippedWeapon;
public void EquipWeapon(Weapon weapon) {
equippedWeapon = weapon;
}
}
I'd like to press a button and create a several instances of the class and save it. So that I can call an instance of this character later.
How do I do that? (I know that I knew how to do this once, so I know enough to know it's an embarassing question to ask)
Thanks for any help
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/Unity3D/com...