unity让摄像机带上碰撞检测

当键盘控制摄像头时会对场景内的物体包括地形穿模,想要设置碰撞检测,在相应地形上设置刚体组件和碰撞组件,一运行就会报错》
问题相关代码,请勿粘贴截图

Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported since Unity 5.
If you want to use a non-convex mesh either make the Rigidbody kinematic or remove the Rigidbody component. Scene hierarchy path "Gaia Terrains/Terrain_0_0-20220819 - 193603/Gaia Game Object Spawns/PW_Stone_02_Moss/_Sp_PW_Stone_02_Moss/PW_Stone_02_01_LOD0", Mesh asset path "Assets/Procedural Worlds/Gaia/Gaia Pro/Assets/Resources/Stones/PW_Stone_02/PW_Stone_02.fbx" Mesh name "PW_Stone_2_LOD3"

我想要达到的结果

就是达到摄像头碰到物体时不会穿模

1.勾选Convex

img

2.有刚体的物体还要勾选isKinematic

img


这篇文章可能会对你有帮助,里面有限制区域功能