change physics to use impulse instead of velocity
This commit is contained in:
1 parent
2d28489f45
commit
7a98cff1a6
2 files changed
+7
-8
No files matched your search
@@ -4,19 +4,18 @@ public class ShipPhysics : MonoBehaviour {
|
|||||||
ShipControls ship;
|
ShipControls ship;
|
||||||
|
|
||||||
float maxDmg = 150f;
|
float maxDmg = 150f;
|
||||||
|
float maxImpulse = 50f;
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
ship = GetComponent<ShipControls>();
|
ship = GetComponent<ShipControls>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnCollisionEnter(Collision collision) {
|
void OnCollisionEnter(Collision collision) {
|
||||||
// Debug-draw all contact points and normals
|
Debug.Log($"mag {collision.relativeVelocity.magnitude}");
|
||||||
// foreach (ContactPoint contact in collision.contacts) {
|
Debug.Log($"impulse {collision.impulse} {collision.impulse.magnitude}");
|
||||||
// Debug.DrawRay(contact.point, contact.normal, Color.white);
|
|
||||||
// }
|
|
||||||
|
|
||||||
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);
|
Debug.Log("Ddddestroyed by" + collision.gameObject.name);
|
||||||
ship.Respawn();
|
ship.Respawn();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ namespace CrosshairComponents {
|
|||||||
Vector2 leftArm = new Vector2(centre.x - angleSin * length, centre.y + angleSin * length);
|
Vector2 leftArm = new Vector2(centre.x - angleSin * length, centre.y + angleSin * length);
|
||||||
|
|
||||||
var painter = context.painter2D;
|
var painter = context.painter2D;
|
||||||
painter.lineWidth = 2.0f;
|
painter.lineWidth = 1.0f;
|
||||||
painter.lineCap = LineCap.Butt;
|
painter.lineCap = LineCap.Butt;
|
||||||
painter.strokeColor = m_TrackColor;
|
painter.strokeColor = m_TrackColor;
|
||||||
|
|
||||||
@@ -184,7 +184,7 @@ namespace CrosshairComponents {
|
|||||||
Vector2 bottomArm = new Vector2(centre.x, centre.y + length);
|
Vector2 bottomArm = new Vector2(centre.x, centre.y + length);
|
||||||
|
|
||||||
var painter = context.painter2D;
|
var painter = context.painter2D;
|
||||||
painter.lineWidth = 2.0f;
|
painter.lineWidth = 1.0f;
|
||||||
painter.lineCap = LineCap.Butt;
|
painter.lineCap = LineCap.Butt;
|
||||||
painter.strokeColor = m_TrackColor;
|
painter.strokeColor = m_TrackColor;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user