Unity两个3D物体碰撞之后获得该点

  public void OnCollisionEnter(Collision collision)
    {
        if (collision.collider.tag == "Wall")//墙
        {
            ContactPoint contact = collision.contacts[0];
            Quaternion rot = Quaternion.FromToRotation(Vector3.up, contact.normal);
            Vector3 pos1 = contact.point;
            Vector3 m_forceHit1 = new Vector3(-pos1.normalized.x, -pos1.normalized.y, -pos1.normalized.z) * 40;
            rigidbody.AddForce(m_forceHit1, ForceMode.Force);
            Debug.Log("最后添加的力是" + m_forceHit1);
            Debug.Log("碰撞之后的位置是" + pos1);
}

}

你可能感兴趣的:(Unity两个3D物体碰撞之后获得该点)