The player character movement is disabled during dialogue
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
using StarterAssets;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Yarn.Unity;
|
using Yarn.Unity;
|
||||||
|
|
||||||
@@ -39,7 +40,10 @@ namespace NightclubArcadia.Dialogue
|
|||||||
|
|
||||||
void StartConversation()
|
void StartConversation()
|
||||||
{
|
{
|
||||||
playerArmature.SetActive(false);
|
var playerController = playerArmature.GetComponent<ThirdPersonController>();
|
||||||
|
if (playerController != null)
|
||||||
|
playerController.enabled = false;
|
||||||
|
|
||||||
dialogueUI.SetActive(true);
|
dialogueUI.SetActive(true);
|
||||||
dialogueRunner.StartDialogue(yarnNodeName);
|
dialogueRunner.StartDialogue(yarnNodeName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using StarterAssets;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Yarn.Unity;
|
using Yarn.Unity;
|
||||||
|
|
||||||
@@ -13,15 +14,26 @@ namespace NightclubArcadia.Dialogue
|
|||||||
[SerializeField] private GameObject dialogueUI;
|
[SerializeField] private GameObject dialogueUI;
|
||||||
[SerializeField] private GameObject playerArmature;
|
[SerializeField] private GameObject playerArmature;
|
||||||
|
|
||||||
|
private ThirdPersonController playerController;
|
||||||
|
|
||||||
void Start()
|
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);
|
dialogueRunner.AddCommandHandler("enter_environment", EnterEnvironment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnterEnvironment()
|
void EnterEnvironment()
|
||||||
{
|
{
|
||||||
dialogueUI.SetActive(false);
|
dialogueUI.SetActive(false);
|
||||||
playerArmature.SetActive(true);
|
if (playerController != null)
|
||||||
|
playerController.enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user