move more stuff over to unity input system

This commit is contained in:
2025-11-21 21:23:33 -08:00
parent 89551b49f3
commit 9ecd6d4cd7
3 changed files with 57 additions and 7 deletions

View File

@@ -1,5 +1,7 @@
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Interactions;
public class MouthOpenClose : MonoBehaviour
{
@@ -59,11 +61,11 @@ public class MouthOpenClose : MonoBehaviour
prompt.SetActive(true);
if (Input.GetKeyDown(KeyCode.E))
{
interacted = true;
prompt.SetActive(false);
text.SetActive(true);
text.GetComponent<TextMeshProUGUI>().text = whatToSay;
timerDeactivate = initialTimerDeactivate;
//interacted = true;
//prompt.SetActive(false);
//text.SetActive(true);
//text.GetComponent<TextMeshProUGUI>().text = whatToSay;
//timerDeactivate = initialTimerDeactivate;
}
}
else
@@ -120,10 +122,27 @@ public class MouthOpenClose : MonoBehaviour
if (text.GetComponent<TextMeshProUGUI>().text != whatToSay) interacted = false;
if (Input.GetKeyDown(KeyCode.C))
{
//text.SetActive(false);
//interacted = false;
}
}
public void OnInteract(InputAction.CallbackContext context)
{
if (context.performed && !interacted && Vector3.Distance(transform.position, player.transform.position) < 3 && context.interaction is TapInteraction)
{
interacted = true;
prompt.SetActive(false);
text.SetActive(true);
text.GetComponent<TextMeshProUGUI>().text = whatToSay;
timerDeactivate = initialTimerDeactivate;
}
if (context.performed && context.interaction is HoldInteraction)
{
text.SetActive(false);
interacted = false;
}
}
}