- Home /
words for a variable definition
is there a possible way to define variables as words instead of boolean, objects, numbers, etc.
Yes, it is indeed possible.
In $$anonymous$$onodevelop or your preferred scripting program, simply type in what you would like a variable to do and the compiler will interpret this for you. For example, you could write this:
I would like my variable to increase every second frame, and to change from true to false whenever I come into contact with collider with tag "foo". Oh, and I would also love it if it could specify my object with the name "foobar" and move it to my player's transform.position. If you could do all that compiler and name my variable "bar", then I'd be super happy.
I think that should work, if not then I think the only way you can typecast is by actually typecasting per se.
Hope this helps, $$anonymous$$lep
Answer by Meltdown · Mar 03, 2012 at 11:12 AM
Yes, you can use something called an enumeration...
i.e
public enum PowerUps { HealthPowerUp, SpeedPowerUp, JumpBooster };
if (pickupType == PowerUps.HealthPowerUp)
health += 20;
@Gamer2470: then maybe you should be more clear when writing your question. Because right now it doesn't really make any sense.
Your answer
Follow this Question
Related Questions
How to access variables between scripts in unity JavaScript? 3 Answers
When I try to increment a variable by 1, why does it add 10? 1 Answer
Best way to handle a lot of variables 3 Answers
Can I have a private Variable "look" in folder? 1 Answer
Passing a set of variables from one script to another 3 Answers