Help| Something strange in my Script..

Hello, I don’t know but I think it bug at Unity 4.6. I have a code:
http://pastebin.com/mwpxk3y2

The problem is “if(!OnGround)” it is called non-stop all the time and it also does not stop the Yield (When also I’m on the Floor).

The OnGround() function:
http://pastebin.com/7pjXrqgF

Why is this happening?

Thanks.

Unity Support? Someone? I’m really need help. I can’t fix it…

I’m guessing that the IsPressing() function does something like this:

return Input.GetKey(KeyCode.A);

The problem is that Input.GetKeyDown will always return true for that frame if the button was pressed… So, you have a do/while loop which will continually check that function which will always return true and you’ll never advance to the next frame.

Try this instead… I didn’t look for or fix any other issues, just the must glaring one to get you started:

private IEnumerator WalkRoutine()
  {
     playerState = PlayerState.Walk;
     if(IsPressing())
     {
        if (!OnGround())
        {
           StartCoroutine(FallRoutine());
           yield break;
           }
    if (Input.GetKeyDown(jumpKey))
    {
      StartCoroutine(JumpRoutine());
      yield break;
  }
  Move();
  yield return null;
  }
  StartCoroutine(IdleRoutine());
  }