This is for unity
I tried another way of stopping player after he dies and it worked fine but now it does not work with sounds
That was my way the only thing that I changed is the state
Ben's was
if (state == state.Alive) { Update() }
Mine was
if (state == state.Dying) { return; }
They look the same but the problem is the Success Sound will not play
Ben's code is working fine with me but I want to understand how it works
is mine the same?
void Update()
{
if (state == State.Dying)
{
return;
}
Rotate();
Thrust();
}
Ben's way
void Update()
{
if (state == State.Alive)
{
Rotate();
Thrust();
}
}
For People Asking For The Enum Definitions:
enum State { Alive, Dying, Transcending }
State state = State.Alive;
State
? Does it have only two possible values or are there others? – John Wu Jan 9 '20 at 21:46State
enum values? If there are more than 2 than the two queries are not equivalent. If you changed your statement toif (state != State.Alive) { return; }
then they would be exactly equivalent. – Berin Loritsch Jan 9 '20 at 21:47Update()
method after the query forState
then returning from the method early will cause all of that to be skipped. – Berin Loritsch Jan 9 '20 at 21:50