In Small Basic you can use While ... .... and EndWhille
For C# you have to ask in a C# forum.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello everybody, I am a 3 month old newby in the C# world. I am following courses and tutorials, i got stuck in this.
I am doing a little program that i want to transfer to unity , about breath cycles.
Inhale, hold, exhale.
I got the if statements to start one when the precedent finishes, but it does it just one time, i.e. inhale, keep, exhale, instead of repeating it till the current time is equal to the total time.
i tried with do, while, other ifs , but it does not work. Thank you in advance for any tips or advises.
Alessio
public float inhale = 2;
public float keepIn = 8;
public float exhale = 4;
public float currentTime = 0;
public float practiceTime = 50;
bool timerIsRunning = false;
bool timerIsRunning2 = false;
bool timerIsRunning3 = false;
Action action;
void Start()
{
textComponent.text = "INHALE";
timerIsRunning = true;
timerIsRunning2 = false;
timerIsRunning3 = false;
}
// Update is called once per frame
void Update()
{
if (practiceTime > currentTime)
{
practiceTime -= Time.deltaTime;
ManageActions();
}
}
private void ManageActions()
{
// if (currentTime < practiceTime)
// {
// do
// {
timerIsRunning = true;
if (timerIsRunning)
{
// inhale
if (inhale > 0)
{
inhale -= Time.deltaTime;
}
else
{
inhale = 0;
timerIsRunning = false;
}
}
// keep in
if (timerIsRunning == false)
{
timerIsRunning2 = true;
if (timerIsRunning2)
{
if (keepIn > 0)
{
textComponent.text = "KEEP IN ";
keepIn -= Time.deltaTime;
}
else
{
keepIn = 0;
timerIsRunning2 = false;
}
}
if (timerIsRunning2 == false)
{
// exhale
timerIsRunning3 = true;
if (timerIsRunning3)
{
textComponent.text = "EXHALE";
if (exhale > 0)
{
exhale -= Time.deltaTime;
}
else
{
exhale = 0;
timerIsRunning3 = false;
}
}
}
}
In Small Basic you can use While ... .... and EndWhille
For C# you have to ask in a C# forum.