Skip to content

Commit

Permalink
Issue ExtendRealityLtd#1288 bux fix scene to restrict bezier pointer …
Browse files Browse the repository at this point in the history
…height with condition met
  • Loading branch information
StevenLech committed Apr 24, 2024
1 parent 22ba0f7 commit 6d6f4a3
Show file tree
Hide file tree
Showing 13 changed files with 1,061 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Assets/Samples/BezierPointerTest.meta

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

81 changes: 81 additions & 0 deletions Assets/Samples/BezierPointerTest/AzimuthCheck.cs
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);
}
}
11 changes: 11 additions & 0 deletions Assets/Samples/BezierPointerTest/AzimuthCheck.cs.meta

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

Loading

0 comments on commit 6d6f4a3

Please sign in to comment.