miepzerino
2025-04-04 18e2f5b45ab0be301f0973b8cf6df714c2d05f7c
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>();