void OnTriggerStay(Collider coll) { if (grabbed) { return; } var g = coll.GetComponentInParent <Socketable>(); if (g) { if (grabCandidate) { if (g.priority > grabCandidate.priority || grabCandidate.IsRetainedByScrews() && !g.IsRetainedByScrews()) { grabCandidate.highlighter.OnHoverEnd(); } else { return; } } grabCandidate = g; g.highlighter.OnHoverBegin(); } }
// Update is called once per frame void Update() { draw = false; if (grabber.grabbed) { Socketable s = grabber.grabbed.GetComponent <Socketable>(); if (s && s.currentSocket) { draw = true; } } if (draw || test) { if (!indicator.gameObject.activeInHierarchy) { indicator.gameObject.SetActive(true); } indicator.Rotate(new Vector3(0, Time.deltaTime * spinSpeed, 0)); bobV += bobSpeed * Time.deltaTime; indicator.localPosition += Vector3.up * Mathf.Sin(bobV) * bobAmount; } if (!test && !draw && indicator.gameObject.activeInHierarchy) { indicator.gameObject.SetActive(false); } }
private void OnTriggerExit(Collider other) { if (other.gameObject == socketable.gameObject) { meshRenderer.enabled = true; socketable = null; } }
void OnTriggerExit(Collider other) { Socketable s = other.GetComponent <Socketable>(); if (s && s == driver.currentScrew) { driver.currentScrew = null; } }
void OnTriggerEnter(Collider other) { Socketable s = other.GetComponent <Socketable>(); if (s && s.socketType == Socket.SocketType.Screw && s.currentSocket) { driver.currentScrew = s; } }
public void TryDrop() { if (grabbed) { myRenderer.enabled = true; grabbed.Drop(); grabbed = null; rotateH = 0; rotateV = 0; } }
public bool TryGrab() { if (grabCandidate && grabCandidate.CanBeRemoved()) { grabbed = grabCandidate; grabCandidate.highlighter.OnHoverEnd(); myRenderer.enabled = false; grabbed.Grab(this); return(true); } return(false); }
void OnTriggerExit(Collider coll) { if (grabbed) { return; } var g = coll.GetComponentInParent <Socketable>(); if (g && g == grabCandidate) { grabCandidate = null; g.highlighter.OnHoverEnd(); } }
public void CanStore(UnityAction onFailed, Socketable socketable, Socket socket) { //filter out what can and can't be socketed if (AllowedIds != null && AllowedIds.Length > 0) { var type = socketable.GetComponent <SocketableType>(); if (type == null || HashedString.DoNotContain(AllowedIds, type.TypeName.Hash)) { //let the inventory know that things are not well onFailed(); return; } } }
private void OnTriggerEnter(Collider other) { // Try to find a socketable socketable = other.GetComponent <Socketable>(); // If there isn't one, exit the method if (socketable == null) { return; } // If this isn't a type we accept, exit the method if (socketable.Type != acceptedSocketableType) { return; } // find the grabbable OVRGrabbable grabbable = other.GetComponent <OVRGrabbable>(); if (grabbable != null && grabbable.isGrabbed) { // Whatever this grabbable is grabbed by // force it to release this grabbable grabbable.grabbedBy.ForceRelease(grabbable); } meshRenderer.enabled = false; socketable.GetComponent <Rigidbody>().isKinematic = true; if (doTween) { StartCoroutine(MoveIntoPlace(socketable.transform, duration)); } else { socketable.transform.position = this.transform.position; socketable.transform.rotation = this.transform.rotation; } }
// Start is called before the first frame update void Start() { mySocketable = GetComponent <Socketable>(); }