Files
nightclub-arcadia/NightclubArcadia/Assets/Scripts/Dialogue/DialogueTransitionController.cs
T

40 lines
1.3 KiB
C#

using StarterAssets;
using UnityEngine;
using Yarn.Unity;
namespace NightclubArcadia.Dialogue
{
/// <summary>
/// Registers the <<enter_environment>> Yarn command, which steps the player
/// out of dialogue and hands control to the 3D environment.
/// </summary>
public class DialogueTransitionController : MonoBehaviour
{
[SerializeField] private DialogueRunner dialogueRunner;
[SerializeField] private GameObject dialogueUI;
[SerializeField] private GameObject playerArmature;
private ThirdPersonController playerController;
void Start()
{
playerController = playerArmature.GetComponent<ThirdPersonController>();
// Dialogue is in progress as soon as this controller is active (including
// auto-started nodes), so the player stays locked out until <<enter_environment>>.
// The armature itself stays active/visible — only its controls are disabled.
if (playerController != null)
playerController.enabled = false;
dialogueRunner.AddCommandHandler("enter_environment", EnterEnvironment);
}
void EnterEnvironment()
{
dialogueUI.SetActive(false);
if (playerController != null)
playerController.enabled = true;
}
}
}