Hey Guys I am hoping someone with a bit more experience can answer a question I have been looking at all night. I am very new to programming in general so there is a chance that I have found my answer but been a bit to uneducated to realize it.
I am making a side scrolling game were the environment constantly pans to the right. Once a section of the environment has panned completely off screen I have a trigger in place to disable the sprite and relocate it. Originally I create 3 bool variants:
bool ZoneActive
bool ZoneReady
bool ZoneIdle
Then by updated the true/false states of these variants, I was able to get the function working as I intended. I then found a post on Enim. From my perspective being able to collapse these 3 variants into a drop down list was a much more suitable method for storing these 3 different states.
After a bit of searching I was able to get my script to a stage were dependent on the state of my enum I was able to access a different section of code. This code can be seen below:
// Update is called once per frame\\
void Update ()
{
switch(CurrentStateOfZone)
{
case ZoneState.Idle:
Debug.Log ("Zone Idle");
break;
case ZoneState.Ready:
Debug.Log ("Zone Ready");
break;
case ZoneState.Active:
Debug.Log ("Zone Active");
break;
}
}
The code I am trying to use to change the enum value can be seen below:
void ZoneCullingFunction ()
{
if(ZoneEnd_A.transform.position.x < -10)
{
Debug.Log("Zone Deactivated");
CurrentStateOfZone = ZoneState.Idle;
}
}
Is what I am trying to do possible? Or can enum only be changed before the game itself is running? I dont want to change to stored values within the enum just with stored value is currently being accessed.
As I said I am very new to programming in general, so dumped down answers would be greatly appreciated. Even if that is just a simple no it down not work.
Thanks Guys