void rotateWheel(float valueToChange) { if (valueToChange > 0.0f) { isRotation = IsRotation.Left; } else if( valueToChange < 0.0f) { isRotation = IsRotation.Right; } if(rotatingEnabled) { this.transform.Rotate (Vector3.up, valueToChange * Time.deltaTime); } }
// Update is called once per frame void Update() { if (GameObject.Find ("Schiff").GetComponent<MoveShip> () != null) { _isGrabbing = true; } else { _isGrabbing = false; } isRotation = IsRotation.Not; if (_handsList.Count > 0) { foreach(GameObject hand in _handsList) { if(hand.name == "unterarm_r") { hydra = SixenseInput.Controllers[1]; } else if(hand.name == "unterarm_l") { hydra = SixenseInput.Controllers[0]; } if (hydra.GetButton (SixenseButtons.TRIGGER)) { //print ("Button from: "+hand.name); if(hand.name == "unterarm_r") { MoveWheel(hydra, hand.name == "unterarm_r", hand, isRightHandRight); } else if(hand.name == "unterarm_l") { MoveWheel(hydra, hand.name == "unterarm_r", hand, isLeftHandRight); } if(!_isGrabbing) { _isGrabbing = true; } } if(hand.name == "unterarm_r") { previousHandPositionRight = hydra.Position; } else if(hand.name == "unterarm_l") { previousHandPositionLeft = hydra.Position; } } } }
void OnTriggerExit(Collider other) { //print (other.name); if (other.name.Contains ("unterarm")) { foreach(GameObject hand in _handsList.ToArray()) { if(other.gameObject.Equals(hand)) { _handsList.Remove(hand); //print ("Hand removed: "+other.gameObject.name); } } if(_handsList.Count == 0) { isRotation = IsRotation.Not; } } }