public void collide(PuckPhysics theirPhys) { float tmp = 1f / (myPhys.m + theirPhys.m); Vector3 newV1 = (((myPhys.m - theirPhys.m) * myPhys.state[1] * tmp) + (theirPhys.m * theirPhys.state[1] * tmp)); Vector3 newV2 = (((theirPhys.m - myPhys.m) * theirPhys.state[1] * tmp) + (myPhys.m * myPhys.state[1] * tmp)); myPhys.state[1] = newV1; theirPhys.state[1] = newV2; }
// Use this for initialization void Start() { myPhys = GetComponent <PuckPhysics>(); otherPhys = new PuckPhysics[otherObjects.Length]; for (int i = 0; i < otherObjects.Length - 1; i++) { otherPhys[i] = otherObjects[i].GetComponent <PuckPhysics>(); } otherTransforms = new Transform[otherObjects.Length]; for (int i = 0; i < otherObjects.Length - 1; i++) { otherTransforms[i] = otherObjects[i].GetComponent <Transform>(); } }