protected void OnCollisionEnter(Collision collision) { if (isCollision) { return; } int layer = collision.gameObject.layer; if (CheckEnableCollision(layer)) { ContactPoint[] contacts = collision.contacts; ContactPoint contact = contacts[0]; Vector3 point = contact.point; if (moveCoroutine != null) { StopCoroutine(moveCoroutine); } animator.enabled = false; //Debug.Log("point==(" + point.x + "," + point.y + "," + point.z + ")" + "; transform.position==(" + transform.position.x + "," + transform.position.y + "," + transform.position.z + ")" // + "; meshFilter.position==(" + meshFilter.transform.position.x + "," + meshFilter.transform.position.y + "," + meshFilter.transform.position.z + ")"); Vector3 colliderPosition = new Vector3(point.x, colliderPos.position.y, point.z); GetMinDistanceFromVerticle(colliderPosition); Vector3 direction = (new Vector3(transform.position.x, colliderPosition.y, transform.position.z) - colliderPosition).normalized; float angleX = Vector3.Angle(new Vector3(direction.x, 0, direction.z), new Vector3(0, 0, 2)); float angleZ = Vector3.Angle(new Vector3(direction.x, 0, direction.z), new Vector3(2, 0, 0)); float rotateX = 0; float rotateZ = 0f; if (angleX > 90) { rotateX = -15f; }else if(angleX < 90) { rotateX = 15f; } if(angleZ > 90) { rotateZ = 15; }else if(angleZ < 90) { rotateZ = -15; } _rigibody.angularDrag = 0; _rigibody.AddForce(new Vector3(40 * direction.x, 80, 40 * direction.z),ForceMode.Impulse); _rigibody.angularVelocity = new Vector3(rotateX, 0, rotateZ); GameManager.Instance.vehicleCrashEffect.transform.position = point; GameManager.Instance.vehicleCrashEffect.SetActive(true); GameManager.Instance.vehicleCrashEffect.GetComponent<ParticleSystem>().Play(); GameAudioManager.Instance.PlayCarContact(); MMVibrationManager.Haptic(HapticTypes.HeavyImpact); isCollision = true; if (!isArrivedLineEnd) { GameEventManager.SendOnVehicleArrivedLineEndEvent(colorIdx); if (this.vehicleType == VEHICLELTYPE.NORMAL) { GameManager.Instance.ArrivedLineEndCnt += 1; isArrivedLineEnd = true; } } } }