123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
-
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class TargetObjDeg : MonoBehaviour
- {
- public bool state;
- public Transform player;
- private float y;
- private Vector3 disPos;
- private float dic;
- private Vector3 dir;
- private Vector3 cross;
- private float dot;
- private float deg;
- private void Start()
- {
- state = false;
- }
- public void FixedUpdate()
- {
- if (!state)
- return;
- dic = Mathf.Abs(Vector3.Distance(player.position, transform.position));
- if (dic < 2.5f)
- {
- dir = player.position - transform.position;
- cross = Vector3.Cross(transform.forward, dir);
- dot = Vector3.Dot(transform.forward, dir.normalized);
- deg = Mathf.Acos(dot) * Mathf.Rad2Deg;
-
-
- Debug.Log("cross.y : " + cross.y + "deg : " + deg);
-
- if (cross.y < 0 && deg >= 165)
- {
- VuforiaManager.Instance.isCorrect = true;
- }
- else if(VuforiaManager.Instance.isCorrect)
- {
- VuforiaManager.Instance.isCorrect = false;
- }
-
-
-
-
- }
- }
- }
|