void OnHitCollider(Collider other) { if (null == m_SkEntity) { return; } if (null != m_PEEntity && m_PEEntity.IsDeath()) { return; } SkEntity hitEntity = other.gameObject.GetComponentInParent <SkEntity>(); bool isTerrain = PETools.PEUtil.IsVoxelOrBlock45(hitEntity); if (null == hitEntity || m_HitEntitys.Contains(hitEntity) || (!isTerrain && !PETools.PEUtil.CanDamage(m_SkEntity, hitEntity))) { return; } m_HitEntitys.Add(hitEntity); PECapsuleHitResult result = null; bool getpos = false; float minDis = 100f; PECapsuleHitResult findResult; for (int i = 0; i < attackParts.Length; i++) { if (!attackParts[i].capsule.enable) { continue; } if (attackParts[i].capsule.GetClosestPos(other.transform.position, out findResult)) { result = findResult; result.selfAttackForm = attackParts[i].attackForm; result.hitTrans = other.transform; result.damageScale = 1f; return; } else if (findResult.distance < minDis) { minDis = findResult.distance; result = findResult; result.hitTrans = other.transform; result.selfAttackForm = attackParts[i].attackForm; result.damageScale = 1f; getpos = true; } } if (getpos) { m_SkEntity.CollisionCheck(result); if (null != onHitSkEntity) { onHitSkEntity(hitEntity); } } }