From 8e04a34d95e82b8ee83ee1bfc39871b2f4a710f1 Mon Sep 17 00:00:00 2001 From: Guderian2nd <gshin3@live.com> Date: Thu, 8 Aug 2019 03:47:32 +0900 Subject: [PATCH] Prepare for model-ui integration --- Assets/Scripts/PathRenderer.cs | 10 ++++++++++ Assets/Scripts/PlayerMovement.cs | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/PathRenderer.cs b/Assets/Scripts/PathRenderer.cs index d29586c..7cb775f 100644 --- a/Assets/Scripts/PathRenderer.cs +++ b/Assets/Scripts/PathRenderer.cs @@ -11,6 +11,8 @@ public class PathRenderer : MonoBehaviour Square square; [SerializeField] GameObject PathColliderPrefab; + [SerializeField] + Camera playercamera; LineRenderer _pathRenderer; float _originalPathColliderY; @@ -31,6 +33,14 @@ public class PathRenderer : MonoBehaviour RaycastHit hit; var ray = Camera.main.ScreenPointToRay(Input.mousePosition); + if (Physics.Raycast(ray, out hit)) + { + ray = playercamera.ViewportPointToRay(hit.textureCoord); + if (Physics.Raycast(ray, out hit)) + { + // hit should now contain information about what was hit through secondCamera + } + } if (Physics.Raycast(ray, out hit)) { if (Input.GetKey(KeyCode.LeftShift)) diff --git a/Assets/Scripts/PlayerMovement.cs b/Assets/Scripts/PlayerMovement.cs index ee19d76..2dadb08 100644 --- a/Assets/Scripts/PlayerMovement.cs +++ b/Assets/Scripts/PlayerMovement.cs @@ -35,7 +35,7 @@ public class PlayerMovement : MonoBehaviour //transform.Translate(0.5f*Vector3.left * Mathf.Sin(2 * Mathf.PI * cnt / 480) * Time.fixedDeltaTime, Space.World); //v = (float)beta * Vector3.forward * Mathf.Cos(2 * Mathf.PI * cnt / 480) + (float)beta * Vector3.left * Mathf.Sin(2 * Mathf.PI * cnt / 480); - v = alpha.normalized * (alpha.magnitude * Time.time / Mathf.Sqrt(1.0f + (alpha.magnitude * Time.time) * (alpha.magnitude * Time.time))); + //v = alpha.normalized * (alpha.magnitude * Time.time / Mathf.Sqrt(1.0f + (alpha.magnitude * Time.time) * (alpha.magnitude * Time.time))); beta = v.magnitude / 1.0f; -- 2.22.0