From ab5a24f4c0cffbc8e8f76e40293f2201027b7c50 Mon Sep 17 00:00:00 2001
From: miepzerino <o.skotnik@gmail.com>
Date: Mon, 07 Apr 2025 22:59:16 +0000
Subject: [PATCH] #49 added parallax and tiling to background

---
 Assets/Scripts/UI/Tiling.cs |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/Assets/Scripts/UI/Tiling.cs b/Assets/Scripts/UI/Tiling.cs
index 1f40aa7..db8e15b 100644
--- a/Assets/Scripts/UI/Tiling.cs
+++ b/Assets/Scripts/UI/Tiling.cs
@@ -1,6 +1,7 @@
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
+using static AnimationStrings;
 
 [RequireComponent(typeof(SpriteRenderer))]
 public class Tiling : MonoBehaviour
@@ -127,6 +128,18 @@
             myTransform.position.z
         );
 
+        // Adjust the new position so it fits with the BoxCollider2D size
+        // Adjust the new position based on whether y is positive or negative
+        float colliderHeight = GetComponent<BoxCollider2D>().size.y;
+        if (newPosition.y >= 0)
+        {
+            newPosition.y -= Mathf.Abs(newPosition.y) % colliderHeight;
+        }
+        else
+        {
+            newPosition.y += Mathf.Abs(newPosition.y) % colliderHeight;
+        }
+
         Transform newBuddy = Instantiate(myTransform, newPosition, myTransform.rotation);
         Tiling buddyTiling = newBuddy.GetComponent<Tiling>();
 

--
Gitblit v1.9.3