PJ/Assets/scripts/dotfs_scripts/Chunk.cs

17 lines
No EOL
713 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
public class Chunk : MonoBehaviour
{
[Header("Connection Points")]
public Transform entrance;
public Transform exit;
// Метод для вычисления смещения, чтобы сопоставить вход этого чанка с выходом предыдущего
public void AlignTo(Vector3 exitPosition)
{
// Вычисляем вектор от входа до центра объекта
Vector3 offset = transform.position - entrance.position;
// Устанавливаем позицию объекта так, чтобы вход совпал с exitPosition
transform.position = exitPosition + offset;
}
}