/// <summary> /// Funcio per al moviment del player /// </summary> /// <param name="player">El player al que se li ha d'aplicar el moviment</param> public static void Move(PlayerBehavior player) { PathManager path = GameObject.Find("Path").GetComponent <PathManager>(); //Path following path.ReachedPoint(player); Vector3 v = path.PathFollowing(player); //Rotation player.transform.rotation = Quaternion.LookRotation(v, player.transform.up); //Mechanics limitation path.ReachedConstrainPointPoint(player); if (path.MechanicConstrains(player)) { player.StopAllCoroutines(); player.canTap = false; player.canDrag = false; path.constrain = true; path.StartCoroutine(path.ResetMechanics(player)); } //Setting velocity float correction = path.ArriveCorrection(player); player.GetComponent <Rigidbody>().velocity = new Vector3(v.x * correction, player.GetComponent <Rigidbody>().velocity.y, v.z * correction); }