c# - StartCoroutine with IEnumerator including Time.deltaTime sometimes infinite loops -


i'm hoping can me issue i'm having creating 2d game. i'm using unity create android application. i'm moving character (a goat) across screen using grid system (gridmove - http://wiki.unity3d.com/index.php/gridmove).

i included global , move script in following links :

global : http://codeshare.io/i6bdn

move : http://codeshare.io/jhdas

in move update function there startcoroutine moves goat position (based on grid size 0.5).

the transform.position gets set vector3.lerp , time.deltatime. on computer works fine, when start opening programs or attach debugger goat seems keep looping in same position. happens on low end phone or samsung galaxy s4.

is there way stop goat resetting transform.position or way check it? can't seem pinpoint goes wrong.

enter image description here

looping goat position : enter image description here

if need more information, let me know.

while (t <= 1f) 

lets think second. want move him position 0f position 1f. if reaches 1f, code will not stop running because condition of position == 1f still satisfies while loop condition.

instead should this:

float threshold = single.epsilon; while ((1f - t) > threshold) 

bigger problem:

//done moving, set bool false "release" update function t = 0; ismoving = false; yield return 0; 

do not end ienumerator yield return 0. exact same thing yield return null, , loop ienumerator on again. reset variables start on position 0f. instead should end ienumerator terminating code. not loop on again:

//done moving, set bool false "release" update function t = 0; ismoving = false; 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -