void OnCollisionStay2D(Collision2D collisionInfo) { SnowPile sp = collisionInfo.gameObject.GetComponent <SnowPile>(); if (sp != null && collect && collectContidiots) { foreach (ContactPoint2D contact in collisionInfo.contacts) { Vector2 hitPoint = contact.point; // Instantiate(explosion,new Vector3(, hitPoint.y, 0), Quaternion.identity); if (sp.GetSnowFromPoint(hitPoint.x + sp.cellSize * (Random.value * 4 - 2)) > 0) { Grow(); } } } }
void OnCollisionEnter2D(Collision2D collisionInfo) { Snowball sb = collisionInfo.gameObject.GetComponent <Snowball>(); if (sb != null) { FixedJoint2D joint = gameObject.AddComponent <FixedJoint2D>(); joint.connectedBody = sb.rb; joint.breakForce = breakforce; joints.Add(joint); return; // Doesn't work yet Debug.Log((KineticEnergy() + sb.KineticEnergy()).magnitude); if ((KineticEnergy() + sb.KineticEnergy()).magnitude > mergeTreshold) { // FixedJoint2D joint = gameObject.AddComponent<FixedJoint2D>(); joint.connectedBody = sb.rb; joint.breakForce = breakforce; joints.Add(joint); } } SnowPile sp = collisionInfo.gameObject.GetComponent <SnowPile>(); if (sp != null) { foreach (ContactPoint2D contact in collisionInfo.contacts) { Vector2 hitPoint = contact.point; // Instantiate(explosion,new Vector3(, hitPoint.y, 0), Quaternion.identity); if (sp.GetSnowFromPoint(hitPoint.x) > 0) { Grow(); } } } }