i3e-asg2/Assets/Scripts/SpaceshipDoor.cs
2024-07-05 01:22:55 +08:00

30 lines
718 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpaceshipDoor : Interactable
{
bool IsOpen = false;
public AudioSource source;
public override void Interact()
{
if (!IsOpen)
{
source.Play();
Vector3 currentRotation = transform.eulerAngles;
currentRotation.z += 115;
transform.eulerAngles = currentRotation;
IsOpen = true;
}
else
{
source.Play();
Vector3 currentRotation = transform.eulerAngles;
currentRotation.z -= 115;
transform.eulerAngles = currentRotation;
IsOpen = false;
}
}
}