22 lines
695 B
C#
22 lines
695 B
C#
using UnityEngine;
|
|
|
|
public class ShipPhysics : MonoBehaviour {
|
|
ShipControls ship;
|
|
|
|
void Awake() {
|
|
ship = GetComponent<ShipControls>();
|
|
}
|
|
|
|
void OnCollisionEnter(Collision collision) {
|
|
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);
|
|
}
|
|
} |