Пример #1
0
        public void OnTriggerEnter(Collider other)
        {
            if (heldBy.Count > 0 && other.GetComponent <PlacePoint>())
            {
                var otherPoint = other.GetComponent <PlacePoint>();
                if (otherPoint == null)
                {
                    return;
                }

                if (placePoint != null && placePoint.PlacedObject() != null)
                {
                    return;
                }

                if (placePoint == null || otherPoint.Distance(transform) < placePoint.Distance(transform))
                {
                    if (otherPoint.CanPlace(transform))
                    {
                        placePoint = other.GetComponent <PlacePoint>();
                        placePoint.Highlight();
                        if (placePoint.callGrabbableHighlight)
                        {
                            Highlight();
                        }
                    }
                }
            }
        }
Пример #2
0
        public void OnTriggerExit(Collider other)
        {
            if (other.GetComponent <PlacePoint>() == null)
            {
                return;
            }

            if (placePoint != null && placePoint.Equals(other.GetComponent <PlacePoint>()) && placePoint.Distance(transform) > 0.01f)
            {
                placePoint.StopHighlight(this);
                if (placePoint.grabbableHighlight)
                {
                    Unhighlight(heldBy[0]);
                }
                placePoint = null;
            }

            if (lastPlacePoint != null && lastPlacePoint.Equals(other.GetComponent <PlacePoint>()) && Vector3.Distance(lastPlacePoint.transform.position, transform.position) > lastPlacePoint.placeRadius)
            {
                lastPlacePoint = null;
            }
        }