private void OnKickOccurred(tnKickable i_Target) { if (i_Target == null) { return; } if (m_Params == null) { return; } if (i_Target.CompareTag(Tags.s_Ball)) { InternalSetVibrationValues(m_Params.kickBallIntensity, m_Params.kickBallDuration); } else { if (i_Target.CompareTag(Tags.s_Character)) { InternalSetVibrationValues(m_Params.kickCharacterIntensity, m_Params.kickCharacterDuration); } } }
private void OnKickOccurred(tnKickable i_Target) { if (m_Results == null) { return; } if (i_Target == null) { return; } if (i_Target.CompareTag(Tags.s_Ball)) { m_Results.shots = m_Results.shots + 1; if (m_OpponentGoal != null) { TSVector2 topPostPosition = m_OpponentGoal.topPostPosition; TSVector2 bottomPostPosition = m_OpponentGoal.bottomPostPosition; TSVector2 currentPosition = tsTransform2D.position; TSVector2 topPostDirection = topPostPosition - currentPosition; topPostDirection.Normalize(); TSVector2 bottomPostDirection = bottomPostPosition - currentPosition; bottomPostDirection.Normalize(); TSVector2 targetPosition = i_Target.tsTransform2D.position; TSVector2 targetDirection = targetPosition - currentPosition; targetDirection.Normalize(); TSVector2 goalPosition = m_OpponentGoal.tsTransform2D.position; TSVector2 goalDirection = goalPosition - currentPosition; goalDirection.Normalize(); FP dot = TSVector2.Dot(targetDirection, goalDirection); if (dot > 0f) { FP angleA = TSVector2.Angle(topPostDirection, TSVector2.up); FP angleB = TSVector2.Angle(bottomPostDirection, TSVector2.up); FP shotAngle = TSVector2.Angle(targetDirection, TSVector2.up); if (shotAngle > angleA && shotAngle < angleB) { m_Results.shotsOnTarget = m_Results.shotsOnTarget + 1; } } } } else { if (i_Target.CompareTag(Tags.s_Character)) { m_Results.tackles = m_Results.tackles + 1; } } }