void OnCollisionEnter(Collision collision) { GameObject collisionObject = collision.gameObject; Player player = collisionObject.GetComponent <Player>(); if (player != null) { if (player.GetId() != _ownerId) { player.DoDamage(damage); } else { return; } } AutoAttack autoAttack = collisionObject.GetComponent <AutoAttack>(); // The reason for the second condition is so that only one of the autoattacks if (autoAttack != null && _ownerId < autoAttack.GetOwnerId()) { float xPosition = (transform.position.x + autoAttack.transform.position.x) / 2; float zPosition = (transform.position.z + autoAttack.transform.position.z) / 2; Vector3 position = new Vector3(xPosition, 1f, zPosition); _gameController.SendBroadcast(new AbilityInput(0, AbilityType.EXPLOSION, position), true); } Destroy(gameObject); }