public override void Init(GrabInstance _first, GrabInstance _second) { base.Init(_first, _second); grabbable.rb.useGravity = true; grabbable.rb.isKinematic = false; inited = true; }
//public float angleTravel = 30f; protected override void CreateGrabHandler(GrabInstance grabInstance) { if (grabInstances.Count == 0) { DestroyImmediate(moveGrabbed); moveGrabbed = null; } else if (grabInstances.Count == 1) { // Do lever grab DestroyImmediate(moveGrabbed); moveGrabbed = gameObject.AddComponent <MoveGrabbedLever>(); moveGrabbed.Init(grabInstances[0]); } else { if (allowMultipleGrabs) { // Do dual hand grab DestroyImmediate(moveGrabbed); moveGrabbed = gameObject.AddComponent <MoveGrabbedLever_Dual>(); moveGrabbed.Init(grabInstances[0], grabInstances[1]); } } }
public override void Init(GrabInstance _grabInstance) { base.Init(_grabInstance); grabbable.rb.useGravity = false; grabbable.rb.isKinematic = true; inited = true; }
void Instance_GrabButtonReleased(object sender, System.EventArgs e) { if (!isTool) { GrabInstance instance = (GrabInstance)sender; DestroyGrabInstance(instance); } }
public void DestroyGrabInstance(GrabZone grabZone) { GrabInstance gi = grabInstances.Find(item => item.grabZone.Equals(grabZone)); if (gi != null) { DestroyGrabInstance(gi); } }
void grabber_GrabInstanceDestroyed(object sender, GrabInstance gi) { if (grabInstance.Equals(gi)) { grabInstance = null; } ConfigureGrabberSphere(null); Destroy(lineRenderer); }
public override void Init(GrabInstance _first, GrabInstance _second) { base.Init(_first, _second); grabbable.rb.useGravity = false; grabbable.rb.isKinematic = true; Debug.Log("Two handed lever created!"); inited = true; }
public override void Init(GrabInstance _first, GrabInstance _second) { base.Init(_first, _second); grabbable.rb.useGravity = false; grabbable.rb.isKinematic = true; // Initialize controller orientation so the update loop doesn't screw up ([0,0,0] previousOrientation). previousControllerOrientation = controllerOrientation; inited = true; }
public virtual void Init(GrabInstance _grabInstance) { firstGrabInstance = _grabInstance; grabbable = firstGrabInstance.grabbable; desiredPosition = grabbable.rb.position; desiredRotation = grabbable.rb.rotation; StoreProperties(); }
public void Init(GrabInstance gi) { grabInstance = gi; haptics = grabInstance.grabber.GetComponent <GrabberHaptics>(); if (haptics == null) { return; } inited = true; }
public GrabInstance Grab(Grabber grabber, GrabZone grabZone) { GrabInstance grabInstance = grabZone.gameObject.AddComponent <GrabInstance>(); grabInstance.Init(this, grabber, grabZone); grabInstance.OnGrabButtonReleased += Instance_GrabButtonReleased; grabInstances.Add(grabInstance); CreateGrabHandler(grabInstance); return(grabInstance); }
void grabber_GrabInstanceCreated(object sender, GrabInstance gi) { // Parent the ball to the grabbed object so it follows it. grabInstance = gi; ConfigureGrabberSphere(gi); // Create the linerenderer lineRenderer = gameObject.AddComponent <LineRenderer>(); UpdateLineRenderer(); }
void HandleGrabInstanceDestroyed(object sender, System.EventArgs e) { // Unsubscribe from events on this grabInstance! GrabInstance gi = (GrabInstance)sender; gi.OnDestroyInstance -= HandleGrabInstanceDestroyed; if (currentGrabInstance.Equals(gi)) { currentGrabInstance = null; } }
public virtual void Init(GrabInstance _first, GrabInstance _second) { firstGrabInstance = _first; secondGrabInstance = _second; grabbable = firstGrabInstance.grabbable; desiredPosition = grabbable.rb.position; desiredRotation = grabbable.rb.rotation; StoreProperties(); }
public override void Init(GrabInstance _grabInstance) { base.Init(_grabInstance); grabbable.rb.useGravity = false; grabbable.rb.isKinematic = true; // Ease in setup (for when coming back from two-handed grabs) if (firstGrabInstance.stretchDistance >= MoveGrabbed.EASE_IN_THRESHOLD) { easeInTimer = MoveGrabbed.EASE_IN_DURATION; } inited = true; }
void ConfigureGrabberSphere(GrabInstance gi = null) { if (gi == null) { // return to center transform.position = grabber.actionPoint.position; transform.parent = grabber.actionPoint; } else { // parent to grabbable, set to attachPoint transform.position = gi.AttachPoint; transform.parent = gi.grabbable.transform; // TODO: Actually set the grabber sphere to the attachpoint if the grabbable.grabZone has one? For tool snaps and such. } }
void HandleGrabButtonDown() { // Nothing grabbed yet if (currentGrabInstance == null) { // Touching something grabbable if (intersecting.Count > 0) { Grabbable grabbable = intersecting[0].grabbable; currentGrabInstance = grabbable.Grab(this, intersecting[0]); currentGrabInstance.OnDestroyInstance += HandleGrabInstanceDestroyed; } } if (GrabButtonDown != null) GrabButtonDown(this, System.EventArgs.Empty); }
public void DestroyGrabInstance(GrabInstance grabInstance) { // Do all the basic stuff here like unsubscribing from events grabInstance.Uninit(); grabInstance.OnGrabButtonReleased -= Instance_GrabButtonReleased; // Remove from bookkeeping and destroy grabInstances.Remove(grabInstance); Destroy(grabInstance); // Reset grab instances if there still are any foreach (GrabInstance gi in grabInstances) { gi.CalcGrabOrientationOffset(); } CreateGrabHandler(grabInstance); }
/// <summary> /// Update the GrabHandler to result in the behaviour that we want. Replace singlehand with doublehand, vice versa, tool or not, snap or not, etc. /// TODO: Create a GrabParameters object to pass here that uses the Grabber, the Grabbable and the GrabZone to determine what to do. /// </summary> /// <param name="grabInstance"></param> protected virtual void CreateGrabHandler(GrabInstance grabInstance) { if (grabInstances.Count == 0) { DestroyImmediate(moveGrabbed); moveGrabbed = null; EnableSnapPreviews(false); } else if (grabInstances.Count == 1) { // Do simple grab DestroyImmediate(moveGrabbed); if (grabInstance.grabZone.isToolGrab) { moveGrabbed = gameObject.AddComponent <MoveGrabbedSingleHand_Tool>(); moveGrabbed.Init(grabInstances[0]); } else { moveGrabbed = gameObject.AddComponent <MoveGrabbedSingleHand>(); moveGrabbed.Init(grabInstances[0]); } EnableSnapPreviews(true); } else if (grabInstances.Count == 2) { if (allowMultipleGrabs) { // Do dual-hand grab DestroyImmediate(moveGrabbed); moveGrabbed = gameObject.AddComponent <MoveGrabbedDualHand>(); moveGrabbed.Init(grabInstances[0], grabInstances[1]); EnableSnapPreviews(true); } } }
public override void Init(GrabInstance _first, GrabInstance _second) { Debug.LogError("Cannot init a MoveGrabbedSlider with two GrabInstances!"); inited = false; }
public override void Init(GrabInstance _grabInstance) { Debug.LogError("Cannot init two-hand force grab with only one grab instance!"); inited = false; }
public override void Init(GrabInstance _grabInstance) { Debug.LogError("Cannot init dual hand MoveGrabbed with only 1 grabInstance!"); inited = false; }
public override void Init(GrabInstance _grabInstance) { Debug.LogError("Cannot init dual hand grab with one grabInstance"); inited = false; }