コード例 #1
0
    private void Update()
    {
        // start checking only if spatial scanning is done
        if (SpatialUnderstanding.Instance.AllowSpatialUnderstanding &&
            SpatialUnderstanding.Instance.ScanState == SpatialUnderstanding.ScanStates.Done)
        {
            RaycastHit hitCamera;
            Physics.Raycast(userCamera.transform.position, Vector3.down, out hitCamera, 10);
            if (counter < arraySize)
            {
                // is user facing next point in path?
                Vector3 targetDir  = targetObjects[counter] - userCamera.transform.position;
                Vector3 camforward = userCamera.transform.forward;
                float   angle      = Vector3.Angle(targetDir, camforward);

                if (hitCamera.collider != null)
                {
                    Debug.Log("hit object is: " + hitCamera.collider.gameObject.name);
                    if (hitCamera.collider.gameObject.name == "MovableObject" && spoken == false)
                    {
                        instructionManager.GiveInstructions("Stop, Turn around slowly");
                        spoken = true;
                    }
                    if (hitCamera.collider.gameObject.name == "MovableObject" && angle <= 20)
                    {
                        enabled = false;
                        Debug.Log("counter in update if check is: " + counter);
                        CheckRayCast(targetObjects[counter]);
                    }
                }
            }
            else
            {
                if (hitCamera.collider.gameObject.name == "MovableObject")
                {
                    instructionManager.GiveInstructions("You have reached your destination");
                    enabled = false;
                }
            }
        }
    }