Files
HCI_GazeLab/Assets/SpaceShooterIgor/Scripts/Environment/SpaceStation3D.cs
T

53 lines
1.5 KiB
C#

using UnityEngine;
using Spaceshooter.Managers;
namespace Spaceshooter.Environment
{
public class SpaceStation3D : MonoBehaviour
{
[Header("Movement & Docking")]
[SerializeField] private float approachSpeed = 2.5f;
[SerializeField] private float targetX = 2.0f;
[SerializeField] private float rotationSpeed = 5f;
private bool isDocked = false;
private bool isApproaching = false;
public bool IsDocked => isDocked;
public void StartApproach()
{
isApproaching = true;
isDocked = false;
}
private void Update()
{
// Subtle 2D Z-rotation (if desired)
transform.Rotate(Vector3.forward * (rotationSpeed * Time.deltaTime));
if (isApproaching && !isDocked)
{
if (transform.position.x > targetX)
{
transform.position += Vector3.left * (approachSpeed * Time.deltaTime);
}
else
{
Vector3 pos = transform.position;
pos.x = targetX;
transform.position = pos;
isDocked = true;
isApproaching = false;
if (GameManager.Instance != null)
{
GameManager.Instance.OnSpaceStationDocked();
}
}
}
}
}
}