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

@@ -59,6 +59,15 @@
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Interact",
"type": "Button",
"id": "659c7039-016f-46e9-948a-517daf323bd7",
"expectedControlType": "",
"processors": "",
"interactions": "Tap,Hold",
"initialStateCheck": false
}
],
"bindings": [
@@ -237,6 +246,28 @@
"action": "Run",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "045d63b8-c118-4d79-a439-5f1fc422a65f",
"path": "<Gamepad>/buttonNorth",
"interactions": "",
"processors": "",
"groups": "",
"action": "Interact",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "96d963c4-bd8d-4dd6-a8c7-fa55d8318aa2",
"path": "<Keyboard>/f",
"interactions": "",
"processors": "",
"groups": "",
"action": "Interact",
"isComposite": false,
"isPartOfComposite": false
}
]
}

Binary file not shown.

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;
}
}
}