From ad8af928065a506d0d28f98d51222d7afa1f47e2 Mon Sep 17 00:00:00 2001 From: miepzerino <o.skotnik@gmail.com> Date: Sat, 05 Apr 2025 14:55:22 +0000 Subject: [PATCH] #47 background rework (static with transitions) --- 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