Update
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.Networking;
|
||||
using Hallucinate.Audio;
|
||||
|
||||
[Serializable]
|
||||
public class Part
|
||||
@@ -44,12 +45,17 @@ public class GerminiNPC : MonoBehaviour
|
||||
public float interactionDistance = 5f; // Khoảng cách tối đa để nói chuyện
|
||||
public Transform playerTransform; // Gán transform của Player vào đây
|
||||
|
||||
[Header("Audio")]
|
||||
public string startTalkSound = "NPC_Interact";
|
||||
public string responseSound = "NPC_Response";
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Keyboard.current != null && Keyboard.current.fKey.wasPressedThisFrame)
|
||||
{
|
||||
if (CanSeePlayer())
|
||||
{
|
||||
AudioManager.Instance?.Play(startTalkSound, position: transform.position);
|
||||
StartCoroutine(GetGerminiReponse());
|
||||
}
|
||||
else
|
||||
@@ -121,6 +127,7 @@ public class GerminiNPC : MonoBehaviour
|
||||
{
|
||||
var npcResponse = geminiResponse.candidates[0].content.parts[0].text;
|
||||
Debug.Log($"<color=green>Tom:</color> {npcResponse}");
|
||||
AudioManager.Instance?.Play(responseSound, position: transform.position);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
Reference in New Issue
Block a user