void playerMoveToBeerPong() { // coffeeRenderer = gameObject.GetComponent<Renderer>(); Player = GameObject.FindGameObjectWithTag("Player"); playerNav = Player.GetComponent <UnityEngine.AI.NavMeshAgent>(); anim = Player.GetComponent <Animator>(); // Check if we've reached the destination if (!playerNav.pathPending) { if (playerNav.remainingDistance <= playerNav.stoppingDistance) { if (!playerNav.hasPath || playerNav.velocity.sqrMagnitude == 0f) { //Debug.Log("Destination not reached yet"); BeerPongReached = true; anim.SetFloat("walking", 0); GameFlowManager GameFlowManager = GameObject.Find("GameFlowManager").GetComponent <GameFlowManager>(); GameFlowManager.MoveFromGameToDrinkToss(); // Done } } } if (playerNav.velocity.sqrMagnitude > 0.2f) { //Debug.Log("player is moving"); anim.SetFloat("walking", 1); } }