void OnTriggerEnter(Collider other) { //Debug.Log(other.gameObject.name); if (other.attachedRigidbody.name.Contains("Car")) { GameplayScript gameplayScript = other.attachedRigidbody.gameObject.GetComponent <GameplayScript>(); if (rigidbodies.ContainsKey(gameplayScript)) { rigidbodies[gameplayScript]++; } if (gameplayScript.AddWaypointIndex(WaypointID)) { Vector3 collisionPosition = other.gameObject.GetComponent <Collider>().ClosestPointOnBounds(transform.position); gameplayScript.SetWaypointPosition(collisionPosition); gameplayScript.SetNormalToWaypoint(Normal); gameplayScript.IncreaseScore(BonusPointsForCrossing); //Debug.Log("Waypoint " + WaypointID + ", point: " + collisionPosition); rigidbodies.Add(gameplayScript, 1); if (IsFinishLine) { gameplayScript.ClearWaypointIndexes(); } } else { if (!rigidbodies.ContainsKey(gameplayScript)) { //Debug.Log("COFNĄŁ SIĘ - UBIT"); gameplayScript.EndGame(); } } } }