diff --git a/POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRing.prefab b/POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRing.prefab index 28f5d10b..995a6aa8 100644 --- a/POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRing.prefab +++ b/POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRing.prefab @@ -60,7 +60,7 @@ MeshRenderer: m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: - - {fileID: 2100000, guid: 909acd5ff84bf424e8f6f20bf4466b56, type: 2} + - {fileID: 2100000, guid: d421d856dd2848d499f3d09a2178c89d, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 diff --git a/POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingMaterial.mat b/POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingSnapped.mat similarity index 95% rename from POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingMaterial.mat rename to POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingSnapped.mat index d6f94140..382fcfc8 100644 --- a/POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingMaterial.mat +++ b/POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingSnapped.mat @@ -7,7 +7,7 @@ Material: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: SnapRingMaterial + m_Name: SnapRingSnapped m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} m_ShaderKeywords: m_LightmapFlags: 4 @@ -73,5 +73,5 @@ Material: - _UVSec: 0 - _ZWrite: 1 m_Colors: - - _Color: {r: 0.4039216, g: 0.91757065, b: 1, a: 1} + - _Color: {r: 0.17292629, g: 0.49835545, b: 0.5471698, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingMaterial.mat.meta b/POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingSnapped.mat.meta similarity index 85% rename from POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingMaterial.mat.meta rename to POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingSnapped.mat.meta index 530f72dd..8b7cb9e1 100644 --- a/POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingMaterial.mat.meta +++ b/POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingSnapped.mat.meta @@ -2,7 +2,7 @@ fileFormatVersion: 2 guid: 909acd5ff84bf424e8f6f20bf4466b56 NativeFormatImporter: externalObjects: {} - mainObjectFileID: 2100000 + mainObjectFileID: 0 userData: assetBundleName: assetBundleVariant: diff --git a/POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingUnsnapped.mat b/POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingUnsnapped.mat new file mode 100644 index 00000000..7f8fe711 --- /dev/null +++ b/POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingUnsnapped.mat @@ -0,0 +1,77 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: SnapRingUnsnapped + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0.57647055, g: 1, b: 0.972549, a: 0.74509805} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingUnsnapped.mat.meta b/POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingUnsnapped.mat.meta new file mode 100644 index 00000000..e38c9f3a --- /dev/null +++ b/POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingUnsnapped.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d421d856dd2848d499f3d09a2178c89d +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/POINT-VR-Chapter-1/Assets/POINT/InputAssets/HandController.cs b/POINT-VR-Chapter-1/Assets/POINT/InputAssets/HandController.cs index 18edebf0..b571caed 100644 --- a/POINT-VR-Chapter-1/Assets/POINT/InputAssets/HandController.cs +++ b/POINT-VR-Chapter-1/Assets/POINT/InputAssets/HandController.cs @@ -89,6 +89,8 @@ public class HandController : MonoBehaviour /// The square of the maximum distance maintained between a pushed object and the hand /// [SerializeField] float squaredMaxPushDistance; + [SerializeField] private Material snapRingSnappedMaterial; + [SerializeField] private Material snapRingUnsnappedMaterial; private bool pushing, holdingSlider, holdingScrollbar, pulling, gravEnabled, teleportMode; private Transform previousParentTransform, grabbingTransform, lastGrabHit; private Color laserColor; @@ -144,7 +146,7 @@ private void Update() if (grabbingTransform != null) // Holding an object { // Prevents the GrabbedTransform from being pushed by other objects - grabbingTransform.GetComponent().velocity = Vector3.zero; + grabbingTransform.GetComponent().velocity = Vector3.zero; // Stores the velocity of the grabbing transform while its grabbed velocityPrev = grabbingTransformVelocity; @@ -154,7 +156,7 @@ private void Update() // Fires a raycast that places the reticle Physics.Raycast(transform.position, transform.forward, out RaycastHit hit, teleportationDistance, floorMask); if (teleportMode && hit.point != Vector3.zero) //In teleport mode and raycast found the floor: place reticle - { + { reticle.SetActive(true); reticle.transform.position = hit.point; reticle.transform.LookAt(new Vector3(playerTransform.parent.position.x, 0f, playerTransform.parent.position.z)); @@ -194,7 +196,8 @@ private void Update() laser.material.color = Color.green; transform.GetComponent().SetBool("isPointing", true); } - } else + } + else { laser.material.color = Color.green; transform.GetComponent().SetBool("isPointing", true); @@ -261,6 +264,11 @@ public void Release() grabbingTransform.localPosition = snapObject.currentAnchor.GetComponent().center; snapObject.currentAnchor.GetComponent().heldObject = snapObject; //snapObject.currentAnchor = null; + Renderer anchorRenderer = snapObject.currentAnchor.GetComponent(); //When released object is snapped, changes snap anchor to snapped material + if (anchorRenderer) + { + anchorRenderer.material = snapRingSnappedMaterial; + } } else @@ -304,6 +312,12 @@ private void Grab(InputAction.CallbackContext ctx) && previousParentTransform && previousParentTransform.GetComponent()) { previousParentTransform.GetComponent().heldObject = null; + Renderer anchorRenderer = previousParentTransform.GetComponent(); //When a player grabs a snapped object, reverts snap anchor to unsnapped material + if (anchorRenderer) + { + anchorRenderer.material = snapRingUnsnappedMaterial; + } + } grabbingTransform.SetParent(transform); grabbingTransform.GetComponent().velocity = Vector3.zero; // Also set the grabbed object's velocity to zero diff --git a/POINT-VR-Chapter-1/Assets/POINT/InputAssets/Player.prefab b/POINT-VR-Chapter-1/Assets/POINT/InputAssets/Player.prefab index 17f7683c..d6a4c694 100644 --- a/POINT-VR-Chapter-1/Assets/POINT/InputAssets/Player.prefab +++ b/POINT-VR-Chapter-1/Assets/POINT/InputAssets/Player.prefab @@ -2114,6 +2114,10 @@ MonoBehaviour: pullSpeed: 0.015 squaredMinPullDistance: 3 squaredMaxPushDistance: 48 + snapRingSnappedMaterial: {fileID: 2100000, guid: 909acd5ff84bf424e8f6f20bf4466b56, + type: 2} + snapRingUnsnappedMaterial: {fileID: 2100000, guid: d421d856dd2848d499f3d09a2178c89d, + type: 2} --- !u!82 &685732245587941450 AudioSource: m_ObjectHideFlags: 0 @@ -11028,6 +11032,10 @@ MonoBehaviour: pullSpeed: 0.015 squaredMinPullDistance: 3 squaredMaxPushDistance: 48 + snapRingSnappedMaterial: {fileID: 2100000, guid: 909acd5ff84bf424e8f6f20bf4466b56, + type: 2} + snapRingUnsnappedMaterial: {fileID: 2100000, guid: d421d856dd2848d499f3d09a2178c89d, + type: 2} --- !u!82 &1016775821658908692 AudioSource: m_ObjectHideFlags: 0 diff --git a/POINT-VR-Chapter-1/Assets/POINT/InputAssets/SnapObject.cs b/POINT-VR-Chapter-1/Assets/POINT/InputAssets/SnapObject.cs index 1b1a73c4..d29b32fa 100644 --- a/POINT-VR-Chapter-1/Assets/POINT/InputAssets/SnapObject.cs +++ b/POINT-VR-Chapter-1/Assets/POINT/InputAssets/SnapObject.cs @@ -14,19 +14,19 @@ public enum SnapTag private void OnTriggerEnter(Collider other) { SnapAnchor anchor = other.GetComponent(); - if (anchor && !currentAnchor && anchor.snapTag == snapTag) + if (anchor && !currentAnchor && anchor.snapTag == snapTag && anchor.heldObject == null) { currentAnchor = other; } } - private void OnTriggerExit(Collider other) { - if (other.GetComponent() && other == currentAnchor) + SnapAnchor anchor = other.GetComponent(); + if (anchor && other == currentAnchor) { - if (other.GetComponent().heldObject == this.gameObject) + if (anchor.heldObject == this.gameObject) { - other.GetComponent().heldObject = null; + anchor.heldObject = null; } currentAnchor = null; } diff --git a/POINT-VR-Chapter-1/Assets/POINT/Scenes/Feature-3.unity b/POINT-VR-Chapter-1/Assets/POINT/Scenes/Feature-3.unity index 73f49eab..ffbec2af 100644 --- a/POINT-VR-Chapter-1/Assets/POINT/Scenes/Feature-3.unity +++ b/POINT-VR-Chapter-1/Assets/POINT/Scenes/Feature-3.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.0069632446, g: 0.0068257754, b: 0.007311784, a: 1} + m_IndirectSpecularColor: {r: 0.0068936315, g: 0.0067525106, b: 0.0071824407, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -1342,6 +1342,10 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: rigidbodiesToDeformAround: [] + size_z: 8 + size_x: 8 + size_y: 5 + divisions: 5 --- !u!23 &385333818 MeshRenderer: m_ObjectHideFlags: 0 @@ -1526,6 +1530,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 20ebf67a7fb99914fafbed8fba9f1f24, type: 3} m_Name: m_EditorClassIdentifier: + unsnappedMaterial: {fileID: 2100000, guid: d421d856dd2848d499f3d09a2178c89d, type: 2} + snappedMaterial: {fileID: 2100000, guid: 909acd5ff84bf424e8f6f20bf4466b56, type: 2} snapTag: 1 currentAnchor: {fileID: 0} --- !u!1 &452855693 @@ -1959,6 +1965,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 20ebf67a7fb99914fafbed8fba9f1f24, type: 3} m_Name: m_EditorClassIdentifier: + unsnappedMaterial: {fileID: 2100000, guid: d421d856dd2848d499f3d09a2178c89d, type: 2} + snappedMaterial: {fileID: 2100000, guid: 909acd5ff84bf424e8f6f20bf4466b56, type: 2} snapTag: 1 currentAnchor: {fileID: 0} --- !u!1 &635734086 @@ -2300,6 +2308,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 20ebf67a7fb99914fafbed8fba9f1f24, type: 3} m_Name: m_EditorClassIdentifier: + unsnappedMaterial: {fileID: 2100000, guid: d421d856dd2848d499f3d09a2178c89d, type: 2} + snappedMaterial: {fileID: 2100000, guid: 909acd5ff84bf424e8f6f20bf4466b56, type: 2} snapTag: 1 currentAnchor: {fileID: 0} --- !u!1 &696779003 @@ -3301,7 +3311,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: eabb63dbfaee8744b8bee074ed1f7757, type: 3} m_Name: m_EditorClassIdentifier: - languageSelected: 0 --- !u!4 &1355089876 Transform: m_ObjectHideFlags: 0 @@ -3686,6 +3695,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 20ebf67a7fb99914fafbed8fba9f1f24, type: 3} m_Name: m_EditorClassIdentifier: + unsnappedMaterial: {fileID: 2100000, guid: d421d856dd2848d499f3d09a2178c89d, type: 2} + snappedMaterial: {fileID: 2100000, guid: 909acd5ff84bf424e8f6f20bf4466b56, type: 2} snapTag: 1 currentAnchor: {fileID: 0} --- !u!1 &1549096207 @@ -3948,9 +3959,10 @@ MonoBehaviour: m_EditorClassIdentifier: snapRingPrefab: {fileID: 6567617309910651400, guid: 01a66bc430f0efd4b8103b9278e6baed, type: 3} + correctSprite: {fileID: 0} + wrongSprite: {fileID: 0} snapRingCount: 5 padding: 0.64 - hardwareController: {fileID: 0} NextTaskButton: {fileID: 914013651} --- !u!1 &1678573033 GameObject: @@ -5053,6 +5065,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 20ebf67a7fb99914fafbed8fba9f1f24, type: 3} m_Name: m_EditorClassIdentifier: + unsnappedMaterial: {fileID: 2100000, guid: d421d856dd2848d499f3d09a2178c89d, type: 2} + snappedMaterial: {fileID: 2100000, guid: 909acd5ff84bf424e8f6f20bf4466b56, type: 2} snapTag: 1 currentAnchor: {fileID: 0} --- !u!1 &2139886021 diff --git a/POINT-VR-Chapter-1/Builds/SnapRingMatSwap.apk b/POINT-VR-Chapter-1/Builds/SnapRingMatSwap.apk new file mode 100644 index 00000000..62f90782 Binary files /dev/null and b/POINT-VR-Chapter-1/Builds/SnapRingMatSwap.apk differ