shields
This commit is contained in:
1 parent
bc0b39c575
commit
6b3f1f5338
5 files changed
+53
-18
No files matched your search
@@ -3,30 +3,20 @@ using UnityEngine;
|
||||
public class ShipPhysics : MonoBehaviour {
|
||||
ShipControls ship;
|
||||
|
||||
float maxDmg = 150f;
|
||||
float maxImpulse = 5000f;
|
||||
|
||||
void Awake() {
|
||||
ship = GetComponent<ShipControls>();
|
||||
}
|
||||
|
||||
void OnCollisionEnter(Collision collision) {
|
||||
float totalForce = collision.impulse.magnitude / Time.fixedDeltaTime;
|
||||
|
||||
Debug.Log($"mag {collision.relativeVelocity.magnitude}");
|
||||
Debug.Log($"impulse {collision.impulse} {collision.impulse.magnitude} {totalForce}");
|
||||
|
||||
// if (collision.relativeVelocity.magnitude > maxDmg) {
|
||||
if (totalForce > maxImpulse) {
|
||||
Debug.Log("Ddddestroyed by" + collision.gameObject.name);
|
||||
ship.Respawn();
|
||||
return;
|
||||
}
|
||||
|
||||
if (collision.gameObject.tag == "TrackLimits") {
|
||||
Debug.Log("Track Limits " + collision.gameObject.name);
|
||||
ship.Respawn();
|
||||
return;
|
||||
}
|
||||
|
||||
float totalForce = collision.impulse.magnitude / Time.fixedDeltaTime;
|
||||
Debug.Log($"mag {collision.relativeVelocity.magnitude}");
|
||||
Debug.Log($"impulse {collision.impulse} {collision.impulse.magnitude} {totalForce}");
|
||||
ship.Damage(totalForce, collision.gameObject.name);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user