From 0b8ecee5142edbc6fdcfe7a483de27f513445a61 Mon Sep 17 00:00:00 2001 From: kookiekenobi Date: Thu, 13 Feb 2025 05:49:32 +0800 Subject: [PATCH] game: handling paper spawn pt2 --- SSLR/Assets/Scenes/LiviPlayground.unity | 53 ++++++++++++++++++++++++- SSLR/Assets/Scripts/GameManager.cs | 1 + SSLR/Assets/Scripts/PaperSpawn.cs | 31 ++++++++++++++- 3 files changed, 82 insertions(+), 3 deletions(-) diff --git a/SSLR/Assets/Scenes/LiviPlayground.unity b/SSLR/Assets/Scenes/LiviPlayground.unity index 08b4106..6e03cda 100644 --- a/SSLR/Assets/Scenes/LiviPlayground.unity +++ b/SSLR/Assets/Scenes/LiviPlayground.unity @@ -3682,12 +3682,18 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 202364687, guid: f6336ac4ac8b4d34bc5072418cdc62a0, type: 3} insertIndex: -1 addedObject: {fileID: 1903054097} + - targetCorrespondingSourceObject: {fileID: 202364687, guid: f6336ac4ac8b4d34bc5072418cdc62a0, type: 3} + insertIndex: -1 + addedObject: {fileID: 1903054104} - targetCorrespondingSourceObject: {fileID: 1670256624, guid: f6336ac4ac8b4d34bc5072418cdc62a0, type: 3} insertIndex: -1 addedObject: {fileID: 1333053557} - targetCorrespondingSourceObject: {fileID: 1670256624, guid: f6336ac4ac8b4d34bc5072418cdc62a0, type: 3} insertIndex: -1 addedObject: {fileID: 1333053556} + - targetCorrespondingSourceObject: {fileID: 1670256624, guid: f6336ac4ac8b4d34bc5072418cdc62a0, type: 3} + insertIndex: -1 + addedObject: {fileID: 1333053563} m_SourcePrefab: {fileID: 100100000, guid: f6336ac4ac8b4d34bc5072418cdc62a0, type: 3} --- !u!1 &442984533 GameObject: @@ -4607,6 +4613,7 @@ MonoBehaviour: dayEnded: 0 shiftStarted: 0 currentNPC: {fileID: 0} + currentStampDoc: {fileID: 0} frontWalkPoints: - {fileID: 1521924626} - {fileID: 2036976913} @@ -11500,6 +11507,27 @@ MonoBehaviour: serializedVersion: 2 m_Bits: 1 m_PhysicsTriggerInteraction: 1 +--- !u!135 &1333053563 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1333053550} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 1 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Radius: 0.03 + m_Center: {x: 0, y: 0, z: -0.04} --- !u!1001 &1351099538 PrefabInstance: m_ObjectHideFlags: 0 @@ -15832,6 +15860,27 @@ MonoBehaviour: serializedVersion: 2 m_Bits: 1 m_PhysicsTriggerInteraction: 1 +--- !u!135 &1903054104 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1903054091} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 1 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Radius: 0.03 + m_Center: {x: 0, y: 0, z: -0.04} --- !u!1 &1921590481 GameObject: m_ObjectHideFlags: 0 @@ -17441,8 +17490,8 @@ Transform: m_GameObject: {fileID: 8749144193474612399} serializedVersion: 2 m_LocalRotation: {x: -0, y: 1, z: -0, w: 0.0000013709068} - m_LocalPosition: {x: 0.04051976, y: 0.509, z: -0.0033783794} - m_LocalScale: {x: 0.4277714, y: 0.016763842, z: 0.9744956} + m_LocalPosition: {x: 0.04051976, y: 0.523, z: -0.0033783794} + m_LocalScale: {x: 0.4277714, y: 0.042896997, z: 0.9744956} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 270371481} diff --git a/SSLR/Assets/Scripts/GameManager.cs b/SSLR/Assets/Scripts/GameManager.cs index 680f45e..06d826d 100644 --- a/SSLR/Assets/Scripts/GameManager.cs +++ b/SSLR/Assets/Scripts/GameManager.cs @@ -23,6 +23,7 @@ public class GameManager : MonoBehaviour public bool shiftStarted; public GameObject currentNPC; + public GameObject currentStampDoc; [Header("Walk Points (FOR DEBUGGING")] public Transform[] frontWalkPoints; diff --git a/SSLR/Assets/Scripts/PaperSpawn.cs b/SSLR/Assets/Scripts/PaperSpawn.cs index eafec9b..bfe36cf 100644 --- a/SSLR/Assets/Scripts/PaperSpawn.cs +++ b/SSLR/Assets/Scripts/PaperSpawn.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.XR.Interaction.Toolkit.Interactables; using UnityEngine.XR.Interaction.Toolkit.Interactors; +using UnityEngine.XR.Interaction.Toolkit; +using UnityEngine.XR; public class PaperSpawn : MonoBehaviour { @@ -10,12 +12,31 @@ public class PaperSpawn : MonoBehaviour private XRDirectInteractor playerHand; private bool handInPaperSpawn = false; + private InputDevice targetDevice; + + void Start() + { + List devices = new List(); + InputDevices.GetDevicesAtXRNode(XRNode.RightHand, devices); + + if (devices.Count > 0) + { + targetDevice = devices[0]; + } + else + { + Debug.LogWarning("No XR Controller detected!"); + } + } + void OnTriggerEnter(Collider other) { if (other.CompareTag("PlayerHand")) { handInPaperSpawn = true; playerHand = other.GetComponent(); + + Debug.Log("Player hand in paper area!"); } } @@ -25,6 +46,8 @@ public class PaperSpawn : MonoBehaviour { handInPaperSpawn = false; playerHand = null; + + Debug.Log("Player hand left paper area!"); } } @@ -32,8 +55,12 @@ public class PaperSpawn : MonoBehaviour { if (handInPaperSpawn && playerHand != null && !playerHand.hasSelection) { - if (Input.GetButtonDown("Select")) + bool isGrabbing = false; + targetDevice.TryGetFeatureValue(CommonUsages.gripButton, out isGrabbing); + + if (isGrabbing) { + Debug.Log("Player hand grabbing in paper area!"); SpawnPaper(); } } @@ -43,6 +70,8 @@ public class PaperSpawn : MonoBehaviour { GameObject spawnedPaper = Instantiate(paperPrefab, playerHand.transform.position, Quaternion.identity); XRGrabInteractable grabComponent = spawnedPaper.GetComponent(); + + Debug.Log("Paper Spawned!"); if (grabComponent != null) {