public override void FixedUpdate() { base.FixedUpdate(); if (!interactable) { return; } if (interactableChildIndex == -1) { InteractableRaw tempInteractable = interactable; interactable = null; SetInteractable(tempInteractable); Debug.Log("WHAT"); return; } if (!(interactable.PrimaryActionEvent == GetDrivePrimaryAction)) { interactable.PrimaryActionEvent = GetDrivePrimaryAction; } EventCalls(); }
public virtual BasicAction GetDrivePrimaryAction(InteractableRaw thisInteractable, InteractorRaw interactor) { //return base.GetPrimaryAction(interactor); Transform offset = thisInteractable.CreateOffset(interactor); //if (driveType == DriveTypes.Directional) // switch (thisInteractable.followType) // { // case FollowType.Transform: // return new DirectionalTransformDriveAction(this, thisInteractable, interactor, offset); // case FollowType.Rigidbody: // return new DirectionalRigidbodyDriveAction(this, thisInteractable, interactor, offset); // case FollowType.Joint: // return new DirectionalDriveJointAction(this, thisInteractable.mainRigidbody, interactor, offset); // } //else if (driveType == DriveTypes.Rotational) // switch (thisInteractable.followType) // { // case FollowType.Transform: // return new RotationalTransformDriveAction(this, thisInteractable, interactor, offset); // case FollowType.Rigidbody: // break; // case FollowType.Joint: // break; // } return(null); }
public InteractableRaw UnGrab(InteractableRaw tryRemove = null) { if (grabbedObjects.Count == 0) { return(null); } InteractableRaw removeObject = null; if (tryRemove) { if (grabbedObjects.Contains(tryRemove)) { removeObject = grabbedObjects[0]; } else { return(null); } } else { removeObject = grabbedObjects[0]; } removeObject.grab.NotifyUnGrab(parent); grabbedObjects.Remove(removeObject); return(removeObject); }
public void UnGrab(InteractableRaw interactable = null) { if (grab.grabbedObjects.Count > 0) { grab.UnGrab(interactable); } }
public void Grab(InteractableRaw interactable, Collider col = null, Collision collision = null) { if (!interactable) { return; } if (grabbedObjects.Contains(interactable)) { return; } grabbedObjects.Add(interactable); //Debug.Log($"{parent.name} Grabbed {interactable.name} : {grabbedObjects.Count}");//publish Debug.Log("Still grabbing _" + parent); interactable.grab.NotifyGrab(parent); //Utils.CleanInteractions.CleanInteractorTouching(interactable, ref parent.touch.touchedObjects); //create data package for grab //publish grab data //GrabProccess(true); //if (interactable.release == InteractableRaw.ReleaseType.Toggle) //{ // GrabProccess(false); //} }
BasicAction GetSecondaryAction(InteractableRaw thisInteractable, InteractorRaw interactor) { BasicAction action = null; switch (secondary) { case SecondGrab.None: action = new NothingAction(thisInteractable, interactor); break; case SecondGrab.Switch: action = new SwitchAction(thisInteractable, interactor); break; case SecondGrab.Scale: break; case SecondGrab.LookAt: var updateType = followType == FollowType.Transform ? UpdateEvents.BeforeRender : UpdateEvents.FixedUpdate; action = new LookAtAction(thisInteractable, interactor, ((FollowAction)grab.grabbedObjects[0].action).offset, true, updateType); break; } return(action); }
public virtual BasicAction GetPrimaryAction(InteractableRaw thisInteractable, InteractorRaw interactor) { Transform offset = thisInteractable.CreateOffset(interactor); switch (thisInteractable.followType) { case FollowType.Transform: if (!thisInteractable.preciseRotate) { return(new GrabFollowTransformAction(thisInteractable, interactor, offset)); } else { return(new GrabFollowTransformPosDifRotAction(thisInteractable, interactor, offset)); } case FollowType.Rigidbody: if (!thisInteractable.preciseRotate) { return(new GrabFollowVelocityAction(thisInteractable, interactor, offset)); } else { return(new GrabFollowRigidbodyForceAtPointAction(thisInteractable, interactor, offset)); } case FollowType.Joint: return(new GrabFollowJointAction(thisInteractable, interactor, offset)); } return(null); }
public GrabData(InteractorRaw _hand, InteractableRaw _interactable, BasicAction _action) { interactor = _hand; interactable = _interactable; action = _action; kinematicOnRelease = interactable.mainRigidbody.isKinematic; gravityOnRelease = interactable.mainRigidbody.useGravity; }
public override void OnEnable() { base.OnEnable(); if (interactable && interactableChildIndex == -1) { InteractableRaw tempInteractable = interactable; interactable = null; SetInteractable(tempInteractable); } }
public override bool FreeChild(int index) { if (interactableChildIndex == index) { interactable.ResetActions(); interactable = null; interactableChildIndex = -1; } return(base.FreeChild(index)); }
public override bool AddChild(GameObject newChild) { if (!interactable) { if (newChild.GetComponent <InteractableRaw>()) { interactable = newChild.GetComponent <InteractableRaw>(); interactable.PrimaryActionEvent = GetDrivePrimaryAction; interactableChildIndex = children.Length; //index when added to array previousPos = interactable.transform.position; } } SetInteractable(newChild.GetComponent <InteractableRaw>()); return(base.AddChild(newChild)); }
public bool SetInteractable(InteractableRaw _interactable) { if (interactable) { return(false); } //adds to children list and if cant be added escapes if (!AddChild(_interactable.gameObject)) { return(false); } interactable = _interactable; interactable.PrimaryActionEvent = GetDrivePrimaryAction; interactableChildIndex = children.Length; //index when added to array previousPos = interactable.transform.position; return(true); }
public virtual void SetInteractable(InteractableRaw _interactable, bool replace) { if (!replace && interactable) { return; } if (replace) { OverrideTarget(_interactable.transform); } else { SetTarget(_interactable.transform); } if (interactable) { interactable.PrimaryActionEvent = interactable.GetPrimaryAction; } interactable = _interactable; interactable.PrimaryActionEvent = GetDrivePrimaryAction; }
public void Grab(InteractableRaw interactable) { grab.Grab(interactable); }