Ejemplo n.º 1
0
 public void DeregisterCollider()
 {
     if (ThisCollider)
     {
         AttachPointMapper.Deregister(ThisCollider);
     }
 }
Ejemplo n.º 2
0
 public void RegisterNewCollider(Collider newCollider)
 {
     if (newCollider)
     {
         ThisCollider = newCollider;
         AttachPointMapper.Register(ThisCollider, this);
     }
 }
Ejemplo n.º 3
0
        protected virtual void Start()
        {
            Rigidbody = Item.Rigidbody;

            // In case of collider not existing in the same entity, then allow user to assign one for this attach point
            ThisCollider = (ThisCollider != null) ? ThisCollider: this.GetComponent <Collider>();
            if (null != ThisCollider)
            {
                AttachPointMapper.Register(ThisCollider, this);
            }
        }
Ejemplo n.º 4
0
        protected virtual void Awake()
        {
            IsAttached = false;

            Item = FindNVRItem(this.gameObject);
            if (Item == null)
            {
                Debug.LogError("No NVRInteractableItem found on this object. " + this.gameObject.name, this.gameObject);
            }

            AttachPointMapper.Register(this.GetComponent <Collider>(), this);
        }
Ejemplo n.º 5
0
        protected virtual void OnTriggerStay(Collider col)
        {
            if (IsAttached == false)
            {
                NVRAttachPoint point = AttachPointMapper.GetAttachPoint(col);
                if (point != null && point.IsAttached == false)
                {
                    float distance = Vector3.Distance(point.transform.position, transform.position);

                    if (distance < AttachRange)
                    {
                        Attach(point);
                    }
                    else
                    {
                        point.PullTowards(this);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        protected virtual void OnTriggerStay(Collider col)
        {
            if (IsAttached == false && CanAttach == true)
            {
                NVRAttachPoint point = AttachPointMapper.GetAttachPoint(col);
                if (point != null && point.IsAttached == false)
                {
                    float distance = Vector3.Distance(point.transform.position, this.transform.position);

                    if (distance < AttachRange)
                    {
                        Attach(point);
                    }
                    else
                    {
                        point.PullTowards(this);
                    }

                    IsTryingToAttach   = true;
                    TryingToAttachItem = col.gameObject.GetComponentInParent <NVRInteractableItem> ();
                }
            }
        }