public void DeregisterCollider() { if (ThisCollider) { AttachPointMapper.Deregister(ThisCollider); } }
public void RegisterNewCollider(Collider newCollider) { if (newCollider) { ThisCollider = newCollider; AttachPointMapper.Register(ThisCollider, this); } }
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); } }
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); }
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); } } } }
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> (); } } }