예제 #1
0
        public void OnTriggerEnter(Collider other)
        {
            if (other.GetComponent <PlacePoint>())
            {
                var otherPoint = other.GetComponent <PlacePoint>();
                if (heldBy.Count == 0 && !otherPoint.onlyPlaceWhileHolding)
                {
                    return;
                }
                if (otherPoint == null)
                {
                    return;
                }

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

                if (placePoint == null)
                {
                    if (otherPoint.CanPlace(transform))
                    {
                        placePoint = other.GetComponent <PlacePoint>();
                        if (placePoint.forcePlace)
                        {
                            if (lastPlacePoint == null || (lastPlacePoint != null && !lastPlacePoint.Equals(placePoint)))
                            {
                                ForceHandsRelease();
                                placePoint.Place(this);
                                lastPlacePoint = placePoint;
                            }
                        }
                        else
                        {
                            placePoint.Highlight(this);
                            if (placePoint.grabbableHighlight)
                            {
                                Highlight(heldBy[0]);
                            }
                        }
                    }
                }
            }
        }
예제 #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;
            }
        }