public void throwBall(GameObject throwableBall) { TxSoftBody tSoft = throwableBall.GetComponent <TxSoftBody>(); try { tSoft.enabled = false; tSoft.transform.position = Camera.main.transform.position + Camera.main.transform.forward * playBallDistance; tSoft.enabled = true; tSoft.ApplyImpulse(Camera.main.transform.forward * ThrowSpeed); } catch { // } }
private void UnSnapObject(object sender, ControllerInteractionEventArgs e) { try { BehaviourModifier mod = this.touchingObject.GetComponent <BehaviourModifier>(); if (mod.IsSoftbody) { TxSoftBody softRB = this.touchingObject.GetComponent <TxSoftBody>(); softRB.enabled = true; softRB.ApplyImpulse(formulaController.Direction * throwMultiplyer); } else { Rigidbody rb = this.touchingObject.GetComponent <Rigidbody>(); rb.velocity = formulaController.Direction * throwMultiplyer; } OnReleased(this.touchingObject, transform.position - lastPosition); } catch { Debug.LogWarning("touching object is null"); } this.touchingObject = null; }