diff --git a/Assets/Scripts/GamePlayer.cs b/Assets/Scripts/GamePlayer.cs index d8ad9f9..0fb1109 100644 --- a/Assets/Scripts/GamePlayer.cs +++ b/Assets/Scripts/GamePlayer.cs @@ -261,14 +261,14 @@ public class GamePlayer : MonoBehaviour if (dir.magnitude < 3f) { berry.GetComponent().linearVelocity = dir.normalized * 5f; - ClampPosition(berry); + ClampPosition(berry, false); } } } } } - void ClampPosition(GameObject obj) + void ClampPosition(GameObject obj, bool modifyY = true) { var cam = Camera.main; var pos = obj.transform.position; @@ -280,7 +280,7 @@ public class GamePlayer : MonoBehaviour UnityEngine.Vector3 max = cam.ViewportToWorldPoint(new UnityEngine.Vector3(1, 1, zDist)); pos.x = Mathf.Clamp(pos.x, min.x + bounds.x, max.x - bounds.x); - pos.y = Mathf.Clamp(pos.y, min.y + bounds.y, max.y - bounds.y); + if (modifyY) pos.y = Mathf.Clamp(pos.y, min.y + bounds.y, max.y - bounds.y); obj.transform.position = pos; } @@ -420,7 +420,7 @@ public class GamePlayer : MonoBehaviour .ToArray(); foreach (GameObject berry in allberries) { - ClampPosition(berry); + ClampPosition(berry, false); } } GameObject[] normalBerries = GameObject.FindGameObjectsWithTag("NormalBerry");