- Home /
Question by
Cvjetkovic · Dec 29, 2015 at 04:09 AM ·
classesinstances
Name instance String variable after instance?
I want to give the variable name the name of the instances created.
For example: I create an instance of the Character-class and name that instance "teddy", now I want teddy.name to be "teddy". If I create an instance called "mandy" Debug.Log(mandy.name) should say "mandy".
How can I do that?
public class Character
{
public var name : String; // = what do I need to assign it to?
public var health : int;
public var level : int;
}
static var teddy : Character = new Character();
static var mandy : Character = new Character();
... also, is it possible the actual name to be "Teddy" starting with a big letter instead of "teddy". Maybe with an if-statement or something?
Thanks for reading my question! ;D
Comment
Your answer
Follow this Question
Related Questions
Problem accessing public instances 1 Answer
Help with passing instances/members around 0 Answers
How to show instance variables in the inspector 1 Answer
Class and instances of the class question. 1 Answer
Creating class instances 1 Answer