Ok im following the Fps Tutorial working on my first weapon script. I came up with the idea of using Enum to allow me to set up my grenade launcher as either a primary fire weapon or a secondary such as an m203 bellow an m16. I know that when you look for input the key is in a string, however how would I use enum as a string?
What do you mean use it as a string?
Are you using C#?
The enum’s ToString() method is designed to return the name of the enum you’ve selected. If you want the underlying value, you’ll have to do that differently.
But say you had an enum… You could use its value as a string like this…
public enum GameState
{
NoPoint,
PointEstablished,
DiceOut
};
GameState gameState = GameState.NoPoint;
// These actually need to be in a method somewhere.
Debug.Log(gameState);
// This is functionally equivalent
Debug.Log(gameState.ToString());
This would print out the values
NoPoint
NoPoint
public enum Blah : string { blah blah}