//protected virtual void Update() //{ // if (rumbling && interactableItem.AttachedHand != null) // { // interactableItem.AttachedHand.TriggerHapticPulse(500); // } //} protected virtual void OnCollisionEnter(Collision collision) { if (!isActiveAndEnabled) { return; } var enemy = collision.gameObject; var enemyHealth = enemy.GetComponent <EnemyHealth>(); if (enemyHealth) { float damage = (collision.relativeVelocity.magnitude) * mDamageScale; enemyHealth.TakeDamage(damage); GetComponent <WeaponHealth>().TakeDamage(damage); if (interactableItem == null) { interactableItem = GetComponent <NewtonVR.NVRInteractableItem>(); } if (interactableItem != null) { if (interactableItem.AttachedHand != null) { rumbling = true; interactableItem.AttachedHand.TriggerHapticPulse(1000, NewtonVR.NVRButtons.Touchpad); } } } }
protected virtual void Attach(NVRAttachPoint point) { point.Attached(this); AttachedItem = point.Item; AttachedPoint = point; }
// Called in Update every frame while being held by a second hand // DON'T LET GO JACK ;( public override void OnSecondHandHold(NewtonVR.NVRInteractableItem nvrIItem) { float distBetweenHands = Vector3.Distance(nvrIItem.AttachedHands[0].transform.position, nvrIItem.AttachedHands[1].transform.position); AdjustBlendShapes(distBetweenHands); // Stretch Weapon ScaleModelToPositions(gameObject, nvrIItem.AttachedHands[0].transform.position, nvrIItem.AttachedHands[1].transform.position); }
// Called in Update every frame while being held by a second hand // DON'T LET GO JACK ;( public virtual void OnSecondHandHold(NewtonVR.NVRInteractableItem nvrIItem) { // Stretch Enemy StretchModelToPositions(enemyModelTransform, nvrIItem.AttachedHands[0].transform.position, nvrIItem.AttachedHands[1].transform.position); // Stretch Weapon if (spawnedWeapon) { ScaleModelToPositions(spawnedWeapon, nvrIItem.AttachedHands[0].transform.position, nvrIItem.AttachedHands[1].transform.position); } }
protected virtual void Detach() { if (AttachedPoint) { AttachedPoint.Detached(this); } AttachedItem = null; AttachedPoint = null; IsTryingToAttach = false; TryingToAttachItem = null; }
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 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 Awake() { IsAttached = false; Item = FindNVRItem(this.gameObject); if (Item == null) { Debug.LogError("No NVRInteractableItem found on this object. " + this.gameObject.name, this.gameObject); } // In case of collider not existing in the same entity, then allow user to assign one for this attach point //Collider thisCollider = (ThisCollider != null) ? ThisCollider: this.GetComponent<Collider>(); //AttachPointMapper.Register(thisCollider, this); }
protected virtual void Detach() { OnDetach(AttachedPoint); AttachedPoint.Detached(this); if (SetKinematicWhenAttached) { AttachedItem.Rigidbody.isKinematic = _itemKinematicStatePreAttach; } // AttachedItem.EndInteraction(); AttachedItem = null; AttachedPoint = null; }
// Use this for initialization void Start() { leftController = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Leftmost); leftController = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Rightmost); rightControlStickOrigin = transform.FindChild("RightControlStickReference"); leftControlStickOrigin = transform.FindChild("LeftControlStickReference"); rightControlStickPosition = transform.FindChild("RightControlStick"); leftControlStickPosition = transform.FindChild("LeftControlStick"); rightInteractableControlStick = transform.FindChild("RightControlStick").GetComponent <NewtonVR.NVRInteractableItem>(); leftInteractableControlStick = transform.FindChild("LeftControlStick").GetComponent <NewtonVR.NVRInteractableItem>(); desiredYRotation = transform.parent.rotation.eulerAngles.y; Debug.Log(transform.parent.name); }
private NVRInteractableItem FindNVRItem(GameObject gameobject) { NVRInteractableItem item = gameobject.GetComponent <NVRInteractableItem>(); if (item != null) { return(item); } if (gameobject.transform.parent != null) { return(FindNVRItem(gameobject.transform.parent.gameObject)); } return(null); }
// Called once one hand lets go. Aka only 1 hand is left holding on public virtual void OnSecondHandReleased(NewtonVR.NVRHand handStillHolding, NewtonVR.NVRInteractableItem nvrIItem) { // End interaction with Enemy handStillHolding.EndInteraction(nvrIItem); // Enable weapon Colliders until ready to be used foreach (Collider c in spawnedWeapon.GetComponentsInChildren <Collider>()) { c.enabled = true; } // Start Interaction with Weapon handStillHolding.BeginInteraction(spawnedWeapon.GetComponent <NewtonVR.NVRInteractable>()); // Destroy Enemy Destroy(gameObject); }
IEnumerator ScanUpward() { burgerDetectionArea.transform.localPosition = startPoint; List <GameObject> ingredients = new List <GameObject> (); float secondsSinceLastIngredient = 0; bool foundNewIngredients = false; GameObject firstPlacard = orderPlacards[0]; var deltaTime = 0.008f; do { foundNewIngredients = false; Bounds bounds = burgerDetectionArea.GetComponent <Renderer>().bounds; Collider[] foundItems = Physics.OverlapBox(bounds.center, bounds.extents, burgerDetectionArea.transform.rotation); foreach (Collider foundItem in foundItems) { Ingredient foundIngredient = foundItem.GetComponent <Ingredient>(); if (foundIngredient && !ingredients.Contains(foundIngredient.gameObject)) { NewtonVR.NVRInteractableItem nvri = foundIngredient.GetComponent <NewtonVR.NVRInteractableItem>(); if (nvri.AttachedHand == null) { foundNewIngredients = true; ingredients.Add(foundIngredient.gameObject); Debug.Log("Found ingredient: " + foundIngredient.ingredientName, foundIngredient.gameObject); } } } if (foundNewIngredients) { secondsSinceLastIngredient = 0; } else { secondsSinceLastIngredient += deltaTime; } burgerDetectionArea.transform.localPosition = burgerDetectionArea.transform.localPosition + movementPerSecond * deltaTime; } while(secondsSinceLastIngredient < 0.05f); transform.localPosition = startPoint; ingredients.TrimExcess(); if (ingredients.Capacity != 0) { FinalizeBurger(transform.parent.gameObject, ingredients); } yield return(null); }
protected virtual void Attach(NVRAttachPoint point) { OnAttach(point); point.Attached(this); AttachedItem = point.Item; AttachedPoint = point; if (SnapToAttachPoint) { AttachedItem.transform.position = transform.position + (AttachedItem.transform.position - AttachedPoint.transform.position); } _itemKinematicStatePreAttach = AttachedItem.Rigidbody.isKinematic; if (SetKinematicWhenAttached) { AttachedItem.Rigidbody.isKinematic = true; } }
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> (); } } }
IEnumerator CheckForPlacard() { while (true) { if (placardsInArea > 0) { bool unattachedBunFound = false; for (int i = 0; i < orderPlacards.Count; i++) { NewtonVR.NVRInteractableItem nvri = orderPlacards[i].GetComponent <NewtonVR.NVRInteractableItem>(); if (nvri != null && nvri.AttachedHand == null) { unattachedBunFound = true; break; } } if (!unattachedBunFound) { yield return(new WaitForSeconds(placardDetectionInterval)); continue; } placardResidentSeconds += placardDetectionInterval; if (placardResidentSeconds >= timeUntilOrderComplete) { yield return(ScanUpward()); placardResidentSeconds = 0; } } else if (placardResidentSeconds > 0) { placardResidentSeconds = 0; } yield return(new WaitForSeconds(placardDetectionInterval)); } }
protected virtual void Detach() { AttachedPoint.Detached(this); AttachedItem = null; AttachedPoint = null; }
protected virtual void Start() { interactableItem = GetComponent <NewtonVR.NVRInteractableItem>(); }
// Use this for initialization void Start() { stringOrigin = stringBone.transform.localPosition; stringCollider = stringBone.GetComponent <Collider>(); interactableString = stringBone.GetComponent <NewtonVR.NVRInteractableItem>(); }
// Called once one hand lets go. Aka only 1 hand is left holding on public override void OnSecondHandReleased(NewtonVR.NVRHand handStillHolding, NewtonVR.NVRInteractableItem nvrIItem) { Destroy(this); }
// Use this for initialization void Start() { i = GetComponent <NewtonVR.NVRInteractableItem> (); r = GetComponent <Rigidbody> (); e = GetComponent <Explo> (); }
protected virtual void OnTriggerExit(Collider col) { IsTryingToAttach = false; TryingToAttachItem = null; }