private IEnumerator LoopFixFreesesCo() { while (true) { _LastPos = transform.position; _fixDirection = Direction; yield return(new WaitForSeconds(3F)); Vector3 _lastNewPos = transform.position; float distance = Vector3.Distance(_LastPos, _lastNewPos); if (distance < 0.15F && _fixDirection == Direction && m_counter > m_maxJumps && Time.time - _lastCollidedTime > 5F) { this.SwapMoving(); Debug.LogError("FIXED FREESE"); } } }
void Start() { rigid = GetComponent <Rigidbody2D> (); //GetComponent<Rigidbody2D> ().velocity = velocity; if (PlayerWallReposer.Instance) { PlayerWallReposer.Instance.SetPlayer(transform.gameObject); } else { Debug.LogError("Bird : Start() : PlayerWallReposer.Instance == null"); } StartCoroutine(RunSpritesLoop()); StartCoroutine(LoopFixFreesesCo()); Direction = PlayeDirection.RIGHT; RefreshjumpsCounterUi(); }
public void SwapMoving() { if (m_direction == Vector3.right) { m_direction = Vector3.left; Direction = PlayeDirection.LEFT; } else { m_direction = Vector2.right; Direction = PlayeDirection.RIGHT; } if (m_JumpSnd_2) { m_JumpSnd_2.Play(); } else { Debug.LogError("Player jump sound == null"); } }