forked from ExtendRealityLtd/VRTK
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue ExtendRealityLtd#1288 bux fix scene to restrict bezier pointer …
…height with condition met
- Loading branch information
1 parent
22ba0f7
commit 6d6f4a3
Showing
13 changed files
with
1,061 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.InputSystem; | ||
|
||
public class AzimuthCheck : MonoBehaviour | ||
{ | ||
public GameObject controller; | ||
public static bool modifyAzimuth = false; | ||
private float initLen = 0f; | ||
private float initAzimuthAngle = 0f; | ||
private float initAltitudeAngle = 0f; | ||
private float curLen = 0f; | ||
private float curAzimuthAngle = 0f; | ||
private float curAltitudeAngle = 0f; | ||
private float maxAzimuthLen = 0f; | ||
|
||
// Start is called before the first frame update | ||
void Start() | ||
{ | ||
if (controller == null) { | ||
controller = GameObject.FindGameObjectWithTag("Controller"); | ||
} | ||
initLen = controller.GetComponent<InputActionProperty>().action.GetBindingIndex(); | ||
initAzimuthAngle = gameObject.transform.rotation.x; | ||
initAltitudeAngle = gameObject.transform.rotation.z; | ||
maxAzimuthLen = initLen; | ||
} | ||
|
||
// Update is called once per frame | ||
void Update() | ||
{ | ||
curAzimuthAngle = gameObject.transform.rotation.x; | ||
curAltitudeAngle = gameObject.transform.rotation.z; | ||
curLen = (float)Math.Cos(initLen * curAzimuthAngle) + (float)Math.Sin(initLen * curAltitudeAngle); | ||
|
||
if (curLen == initLen) { | ||
return; | ||
} | ||
if (curAzimuthAngle > initAzimuthAngle) { | ||
if (curAltitudeAngle > initAltitudeAngle) { | ||
modifyAzimuth = true; | ||
} | ||
else { | ||
modifyAzimuth = false; | ||
} | ||
} | ||
else { | ||
if (curAltitudeAngle > initAltitudeAngle) { | ||
modifyAzimuth = false; | ||
} | ||
else { | ||
modifyAzimuth = true; | ||
} | ||
} | ||
if (curAltitudeAngle > initAltitudeAngle) { | ||
if (curAzimuthAngle > initAzimuthAngle) { | ||
modifyAzimuth = false; | ||
} | ||
else { | ||
modifyAzimuth = true; | ||
} | ||
} | ||
else { | ||
if (curAzimuthAngle > initAzimuthAngle) { | ||
modifyAzimuth = true; | ||
} | ||
else { | ||
modifyAzimuth = false; | ||
} | ||
} | ||
} | ||
|
||
void LateUpdate() { | ||
if (modifyAzimuth) { | ||
curLen /= (float)(Math.Sqrt(3) / 2); | ||
} | ||
controller.transform.position = new Vector3(controller.transform.position.x, controller.transform.position.y, controller.transform.position.z - curLen); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.