// Update is called once per frame void Update() { Debug.DrawLine(trans.transform.position, trans2.transform.position, Color.cyan); DrawPoint(Vector3.zero, 10f); DrawPoint(trans.transform.position, 0.2f); DrawPoint(trans2.transform.position, 0.2f); projectTZ(trans, trans2); projectTX(trans, trans2); projectTY(trans, trans2); FangleZ(trans, trans2); FangleX(trans, trans2); FangleY(trans, trans2); Vector3 tdir = (trans2.transform.position - trans.transform.position).normalized; Debug.DrawLine(trans.transform.position, trans.transform.position + tdir, Color.black); Vector3 kk = new Vector3(Mathf.Sin(XX * Mathf.Deg2Rad), Mathf.Sin(YY * Mathf.Deg2Rad), Mathf.Sin(ZZ * Mathf.Deg2Rad)); /////Main Torque force aplied here/////////////// mart.AddTorque(kk * WWtorque); //mart.AddForceAtPosition(tdir * WWtorque, trans.transform.position); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { artbb.AddRelativeTorque(Tvec); } if (Input.GetKeyDown(KeyCode.Return)) { artbb.AddTorque(Tvec); } }
// Update is called once per frame void FixedUpdate() { if (targetBody == null) { return; } if (positionToForce.Equals(Vector3.zero)) { targetBody.AddForce(force); } else { targetBody.AddForceAtPosition(force, positionToForce); } targetBody.AddRelativeForce(relativeForce); targetBody.AddTorque(torque); targetBody.AddRelativeTorque(relativeTorque); for (var index = 0; index < targetBody.jointForce.dofCount; index++) { jointForce[index] = targetBody.jointForce[index]; } for (var index = 0; index < targetBody.jointAcceleration.dofCount; index++) { jointAcceleration[index] = targetBody.jointAcceleration[index]; } for (var index = 0; index < targetBody.jointVelocity.dofCount; index++) { jointVelocity[index] = targetBody.jointVelocity[index]; } for (var index = 0; index < targetBody.jointPosition.dofCount; index++) { jointPosition[index] = targetBody.jointPosition[index]; } }