change physics to use impulse instead of velocity
This commit is contained in:
1 parent
90dfa02659
commit
05cc5244ea
2 files changed
+7
-8
No files matched your search
@@ -4,19 +4,18 @@ public class ShipPhysics : MonoBehaviour {
|
||||
ShipControls ship;
|
||||
|
||||
float maxDmg = 150f;
|
||||
float maxImpulse = 50f;
|
||||
|
||||
void Awake() {
|
||||
ship = GetComponent<ShipControls>();
|
||||
}
|
||||
|
||||
void OnCollisionEnter(Collision collision) {
|
||||
// Debug-draw all contact points and normals
|
||||
// foreach (ContactPoint contact in collision.contacts) {
|
||||
// Debug.DrawRay(contact.point, contact.normal, Color.white);
|
||||
// }
|
||||
Debug.Log($"mag {collision.relativeVelocity.magnitude}");
|
||||
Debug.Log($"impulse {collision.impulse} {collision.impulse.magnitude}");
|
||||
|
||||
Debug.Log("mag" + collision.relativeVelocity.magnitude);
|
||||
if (collision.relativeVelocity.magnitude > maxDmg) {
|
||||
// if (collision.relativeVelocity.magnitude > maxDmg) {
|
||||
if (collision.impulse.magnitude > maxImpulse) {
|
||||
Debug.Log("Ddddestroyed by" + collision.gameObject.name);
|
||||
ship.Respawn();
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user