protected override void Choc(PhysicsSphere sphere, float energyDissipation = 0f) { //Debug.Log("choc: " + name); if (IsColliding(sphere) == false) { return; } if (spaced) // Yeet the ball { sphere.transform.position = CorrectedPosition(sphere); sphere.Velocity = Normal * ballPushForce; return; } if (IsSphereStaticOnBox(sphere)) { sphere.transform.position = CorrectedPosition(sphere); sphere.ApplyForce(-sphere.mass * Physics.gravity); } else { sphere.transform.position = CorrectedPosition(sphere); InverseRelativeVelocity(sphere, Reflect(RelativeVelocity(sphere))); } }
/// <summary> /// /// </summary> /// <param name="sphere"></param> /// <param name="energyDissipation" the impact of the energy dissipation on the reflected velocity></param> protected override void Choc(PhysicsSphere sphere, float energyDissipation = 0f) { //Debug.Log("choc: " + name); if (IsColliding(sphere) == false) { return; } //Debug.Log("Sphere plane collision on: " + name); //Debug.Log("Velocity Error: isVerlet: " + sphere.isVerlet + " " + sphere.ErrorVelocityOnTheGround()); //sphere.Velocity = Vector3.Reflect(sphere.Velocity, Normal); if (IsSphereStaticOnPlane(sphere)) { sphere.transform.position = CorrectedPosition(sphere); sphere.ApplyForce(-sphere.mass * Physics.gravity); } else // sphere is dynamic { sphere.transform.position = CorrectedPosition(sphere); InverseRelativeVelocity(sphere, Reflect(RelativeVelocity(sphere), energyDissipation)); //sphere.Velocity = Reflect(RelativeVelocity(sphere), energyDissipation); } }
/// <summary> /// /// </summary> /// <param name="sphere"></param> /// <param name="energyDissipation" the impact of the energy dissapation on the reflected velocity></param> public void Chock(PhysicsSphere sphere, float energyDissipation = 0) { if (isColliding(sphere) == false) { return; } //Debug.Log("Velocity Error: isVerlet " + sphere.isVerlet + " " + sphere.ErrorVelocityOnGround()); if (IsSphereStatic(sphere)) { sphere.transform.position = CorrectedPosition(sphere); sphere.ApplyForce(-sphere.Mass * Physics.gravity); } else //sphere is dynamic { sphere.Velocity = Reflect(sphere.Velocity, energyDissipation); } }