From c02a9fffe5d2cb2469814e795ec127325ab9b3a9 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sun, 30 Jan 2022 11:20:24 +0000 Subject: [PATCH 1/3] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index e27ee61..192d589 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +Humanoid Control 5 branch +========================= +This branch contains *experimental* code which may become part of the future Humanoid Control 5 release. + +More to come .... + Installation ============ Import this package in Unity directlywith the Package Manager git package importer From a222f1e64f73909dc613771fab8acba000818703 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sun, 30 Jan 2022 15:26:22 +0100 Subject: [PATCH 2/3] Added InteractionPointer focusDistance --- Runtime/Tools/Scripts/InteractionPointer.cs | 22 ++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Runtime/Tools/Scripts/InteractionPointer.cs b/Runtime/Tools/Scripts/InteractionPointer.cs index fae84f3..49ae11f 100644 --- a/Runtime/Tools/Scripts/InteractionPointer.cs +++ b/Runtime/Tools/Scripts/InteractionPointer.cs @@ -129,6 +129,12 @@ namespace Passer { /// The value is null when the pointer is not reaching any object. public GameObject objectInFocus; + /// + /// Distance to the objectInFocus + /// + /// This is float.infintiy when no object is in focus + public float focusDistance; + //protected new EventSystem eventSystem; //protected PointerEventData data; protected InteractionModule interactionModule; @@ -332,6 +338,7 @@ namespace Passer { focusPointObj.SetActive(false); focusPointObj.transform.position = transform.position; objectInFocus = null; + focusDistance = float.PositiveInfinity; hasClicked = false; } } @@ -349,9 +356,11 @@ namespace Passer { focusPosition = hit.point; focusRotation = Quaternion.LookRotation(hit.normal); objectInFocus = hit.transform.gameObject; + focusDistance = hit.distance; } else { objectInFocus = null; + focusDistance = float.PositiveInfinity; } focusPointObj.transform.position = focusPosition; @@ -379,7 +388,6 @@ namespace Passer { focusPointObj.transform.position = focusPosition; // bezierPositions[bezierPositions.Length - 1]; focusPointObj.transform.rotation = focusRotation; // Quaternion.LookRotation(normal, transform.forward); - for (int i = 0; i < bezierPositions.Length; i++) bezierPositions[i] = focusPointObj.transform.InverseTransformPoint(bezierPositions[i]); @@ -406,21 +414,22 @@ namespace Passer { } intermediatePosition = Vector3.forward * distance; - Debug.DrawLine(this.transform.position, transform.TransformPoint(intermediatePosition)); + //Debug.DrawLine(this.transform.position, transform.TransformPoint(intermediatePosition)); RaycastHit rayHit; if (Physics.Raycast(transform.TransformPoint(intermediatePosition), Vector3.down, out rayHit)) { normal = rayHit.normal; focusObject = rayHit.transform.gameObject; + focusDistance = Vector3.Distance(transform.position, rayHit.point); endPosition = transform.InverseTransformPoint(rayHit.point); for (int i = 0; i <= nCurveSegments; i++) curvePoints[i] = GetPoint(i / (float)nCurveSegments, transform); - } else { normal = Vector3.up; focusObject = null; + focusDistance = float.PositiveInfinity; } return curvePoints; @@ -484,6 +493,7 @@ namespace Passer { Vector3 segVelocity = transform.forward * forwardSpeed; normal = Vector3.up; hitObject = null; + focusDistance = float.PositiveInfinity; for (int i = 1; i < nCurveSegments + 1; i++) { if (hitObject != null) { @@ -501,6 +511,7 @@ namespace Passer { if (Physics.Raycast(curvePoints[i - 1], segVelocity.normalized, out hit, resolution)) { normal = hit.normal; hitObject = hit.transform.gameObject; + focusDistance = Vector3.Distance(transform.position, hit.point); // set next position to the position where we hit the physics object curvePoints[i] = curvePoints[i - 1] + segVelocity.normalized * hit.distance; @@ -511,9 +522,11 @@ namespace Passer { } } } + #endregion #region Spherecast + /// The radius of the sphere in a SphereCast public float radius = 0.1F; @@ -521,16 +534,19 @@ namespace Passer { RaycastHit hit; if (Physics.SphereCast(transform.position, radius, transform.forward, out hit, maxDistance)) { objectInFocus = hit.transform.gameObject; + focusDistance = hit.distance; focusPointObj.transform.position = hit.point; focusPointObj.transform.rotation = Quaternion.LookRotation(hit.normal, transform.forward); } else { objectInFocus = null; + focusDistance = float.PositiveInfinity; focusPointObj.transform.position = transform.position + transform.forward * maxDistance; focusPointObj.transform.rotation = Quaternion.identity; } } + #endregion #endregion From 1b875d9f56a93f6dd7d28ed146270b9225266d6d Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sun, 30 Jan 2022 14:37:34 +0000 Subject: [PATCH 3/3] Update README.md --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index 192d589..e27ee61 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,3 @@ -Humanoid Control 5 branch -========================= -This branch contains *experimental* code which may become part of the future Humanoid Control 5 release. - -More to come .... - Installation ============ Import this package in Unity directlywith the Package Manager git package importer