private void OnCollisionEnter(Collision other) { if (hasHit) { return; } hasHit = true; if (OnHit != null) { OnHit.Invoke(origin, other.contacts[0].point, other.gameObject); } if (hitEffect != null) { GameObject g = Instantiate(hitEffect, transform.position, Quaternion.identity); foreach (ParticleSystem p in g.GetComponentsInChildren <ParticleSystem>()) { var main = p.main; main.startColor = player.Color.ScaleHSV(main.startColor.color, multiplyBaseValue: false); } g.GetComponent <ParticleSystem>()?.Play(true); } //GetComponent<MeshRenderer>().enabled = false; if (projectileRenderer != null) { projectileRenderer.SetActive(false); } Rigidbody rb = GetComponent <Rigidbody>(); rb.detectCollisions = false; rb.collisionDetectionMode = CollisionDetectionMode.Discrete; rb.isKinematic = true; Destroy(gameObject, 2); }
public void Hit(object btn, EventArgs args) { Hit((btn as Button).Coordinates()); HitAction?.Invoke(); }