Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRing.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 77 additions & 0 deletions POINT-VR-Chapter-1/Assets/POINT/Feature3/SnapRingUnsnapped.mat
Original file line number Diff line number Diff line change
@@ -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}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions POINT-VR-Chapter-1/Assets/POINT/InputAssets/HandController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public class HandController : MonoBehaviour
/// The square of the maximum distance maintained between a pushed object and the hand
/// </summary>
[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;
Expand Down Expand Up @@ -144,7 +146,7 @@ private void Update()
if (grabbingTransform != null) // Holding an object
{
// Prevents the GrabbedTransform from being pushed by other objects
grabbingTransform.GetComponent<Rigidbody>().velocity = Vector3.zero;
grabbingTransform.GetComponent<Rigidbody>().velocity = Vector3.zero;

// Stores the velocity of the grabbing transform while its grabbed
velocityPrev = grabbingTransformVelocity;
Expand All @@ -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));
Expand Down Expand Up @@ -194,7 +196,8 @@ private void Update()
laser.material.color = Color.green;
transform.GetComponent<Animator>().SetBool("isPointing", true);
}
} else
}
else
{
laser.material.color = Color.green;
transform.GetComponent<Animator>().SetBool("isPointing", true);
Expand Down Expand Up @@ -261,6 +264,11 @@ public void Release()
grabbingTransform.localPosition = snapObject.currentAnchor.GetComponent<BoxCollider>().center;
snapObject.currentAnchor.GetComponent<SnapAnchor>().heldObject = snapObject;
//snapObject.currentAnchor = null;
Renderer anchorRenderer = snapObject.currentAnchor.GetComponent<Renderer>(); //When released object is snapped, changes snap anchor to snapped material
if (anchorRenderer)
{
anchorRenderer.material = snapRingSnappedMaterial;
}

}
else
Expand Down Expand Up @@ -304,6 +312,12 @@ private void Grab(InputAction.CallbackContext ctx)
&& previousParentTransform && previousParentTransform.GetComponent<SnapAnchor>())
{
previousParentTransform.GetComponent<SnapAnchor>().heldObject = null;
Renderer anchorRenderer = previousParentTransform.GetComponent<Renderer>(); //When a player grabs a snapped object, reverts snap anchor to unsnapped material
if (anchorRenderer)
{
anchorRenderer.material = snapRingUnsnappedMaterial;
}

}
grabbingTransform.SetParent(transform);
grabbingTransform.GetComponent<Rigidbody>().velocity = Vector3.zero; // Also set the grabbed object's velocity to zero
Expand Down
8 changes: 8 additions & 0 deletions POINT-VR-Chapter-1/Assets/POINT/InputAssets/Player.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions POINT-VR-Chapter-1/Assets/POINT/InputAssets/SnapObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ public enum SnapTag
private void OnTriggerEnter(Collider other)
{
SnapAnchor anchor = other.GetComponent<SnapAnchor>();
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<SnapAnchor>() && other == currentAnchor)
SnapAnchor anchor = other.GetComponent<SnapAnchor>();
if (anchor && other == currentAnchor)
{
if (other.GetComponent<SnapAnchor>().heldObject == this.gameObject)
if (anchor.heldObject == this.gameObject)
{
other.GetComponent<SnapAnchor>().heldObject = null;
anchor.heldObject = null;
}
currentAnchor = null;
}
Expand Down
20 changes: 17 additions & 3 deletions POINT-VR-Chapter-1/Assets/POINT/Scenes/Feature-3.unity
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
Binary file added POINT-VR-Chapter-1/Builds/SnapRingMatSwap.apk
Binary file not shown.