30 lines
820 B
C#
30 lines
820 B
C#
using UnityEngine;
|
|
|
|
public class TrackLimits : MonoBehaviour {
|
|
ShipControls ship;
|
|
|
|
float maxDmg = 5000f;
|
|
|
|
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);
|
|
// }
|
|
|
|
if (collision.relativeVelocity.magnitude > maxDmg) {
|
|
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;
|
|
}
|
|
}
|
|
} |