// TrueSyncBehaviour's interface public override void OnSyncedTriggerEnter(TSCollision2D i_Collision) { if (!i_Collision.collider.CompareTag(Tags.s_Ball)) { return; } if (m_TeamId == Hash.s_NULL) { return; } tnGoalEventParams goalEventParams = new tnGoalEventParams(); goalEventParams.SetTeamId(m_TeamId); goalEventParams.SetHasValidScorer(false); { // Try to assign a valid scorer. tnKickable kickable = i_Collision.gameObject.GetComponent <tnKickable>(); if (kickable != null) { for (int touchIndex = 0; touchIndex < kickable.touchesCount; ++touchIndex) { tnTouch ballTouch = kickable.GetTouch(touchIndex); if (m_TeamId != ballTouch.teamId) { goalEventParams.SetScorerId(ballTouch.characterId); goalEventParams.SetScorerTeamId(ballTouch.teamId); goalEventParams.SetIsHumanScorer(ballTouch.isHuman); goalEventParams.SetIsLocalScorer(ballTouch.isLocal); goalEventParams.SetHasValidScorer(true); break; } } } } // Send event. Messenger.Broadcast <tnGoalEventParams>("Goal", goalEventParams); }