Exemplo n.º 1
0
 //reset getting the plane
 public void ResetGettingPlane()
 {
     for (int i = 0; i < areaPlanes.Count; i++)
     {
         areaPlanes.RemoveAt(0);
     }
     CurrentGameState = playstates.PlaneSearch;
     cats[currentCatValue].SetActive(false);
 }
Exemplo n.º 2
0
    void FindPlane()
    {
        PlaneCountText.text = "count: " + areaPlanes.Count;

        Frame.GetNewPlanes(ref areaPlanes);

        // Iterate over planes found in this frame and instantiate corresponding GameObjects to visualize them.
        for (int i = 0; i < areaPlanes.Count; i++)
        {
            // Instantiate a plane visualization prefab and set it to track the new plane.
            GameObject planeObject = Instantiate(plane, Vector3.zero, Quaternion.identity,
                                                 transform);
            planeObject.GetComponent <PlaneVisualizer>().SetPlane(areaPlanes[i]);
        }

        if (areaPlanes.Count > 0)
        {
            // planefound = true;
            CurrentGameState    = playstates.CatPlacement;
            PlaneCountText.text = "count: " + areaPlanes.Count;
            TestingText.text    = "plane found";
        }
    }
Exemplo n.º 3
0
    void AnchorCatPlacement()
    {
        // See if user made an touch event
        Touch touch;

        if (Input.touchCount < 1 || (touch = Input.GetTouch(0)).phase != TouchPhase.Began)
        {
            return;
        }

        TrackableHit hitResult;
        // Create a raycast filter
        TrackableHitFlag raycastFilter = TrackableHitFlag.PlaneWithinBounds | TrackableHitFlag.PlaneWithinPolygon;

        // Create a Raycast with touch position, filters and hitResult object
        if (Session.Raycast(cam.ScreenPointToRay(touch.position), raycastFilter, out hitResult))
        {
            // Create an anchor to allow ARCore to track the hitpoint as understanding of the physical
            // world evolves.
            if (hitResult.Plane == areaPlanes[0])
            {
                mainAnchor       = Session.CreateAnchor(hitResult.Point, Quaternion.identity);
                CurrentGameState = playstates.InGame;
                TestingText.text = "Ready to play";
                UIManager.instance.EnableGamePlayUI();

                //change to work with new cats
                cats[0].gameObject.SetActive(true);
                cats[0].transform.position = hitResult.Point;
                cats[0].transform.parent   = mainAnchor.transform;
                cats[0].transform.rotation = Quaternion.identity;
                mainCat = cats[0].gameObject;
                UIManager.instance.setAttributes();
                UIManager.instance.StartTimer();
            }
        }
    }