前言
上一期我们简单的使用了StateDrivenCamera相机,这次我们来使用一下ClearShot
使用ClearShot完成根据模型位置自动切换不同的相机
1. 创建一个游戏物体
![图片[1]-Unity3d Cinemachine篇(五)— ClearShot-灵码CV](https://www.0cv.com/wp-content/uploads/2025/07/image-36.png)
2. 创建ClearShot相机
![图片[2]-Unity3d Cinemachine篇(五)— ClearShot-灵码CV](https://www.0cv.com/wp-content/uploads/2025/07/image-37.png)
游戏物体比较远不方便调试
![图片[3]-Unity3d Cinemachine篇(五)— ClearShot-灵码CV](https://www.0cv.com/wp-content/uploads/2025/07/image-38.png)
选中Virtual Camera相机
![图片[4]-Unity3d Cinemachine篇(五)— ClearShot-灵码CV](https://www.0cv.com/wp-content/uploads/2025/07/image-39.png)
使用快捷键聚焦到游戏物体
![图片[5]-Unity3d Cinemachine篇(五)— ClearShot-灵码CV](https://www.0cv.com/wp-content/uploads/2025/07/image-40.png)
3. 设置相机和层级
给cube设置一个player层级
![图片[6]-Unity3d Cinemachine篇(五)— ClearShot-灵码CV](https://www.0cv.com/wp-content/uploads/2025/07/image-41.png)
创建一个障碍物并把他的层级设置成Obstacle
![图片[7]-Unity3d Cinemachine篇(五)— ClearShot-灵码CV](https://www.0cv.com/wp-content/uploads/2025/07/image-42.png)
点击CM ClearShot1设置Follow和LookAt属性
![图片[8]-Unity3d Cinemachine篇(五)— ClearShot-灵码CV](https://www.0cv.com/wp-content/uploads/2025/07/image-43.png)
点击+添加一个新的相机
![图片[9]-Unity3d Cinemachine篇(五)— ClearShot-灵码CV](https://www.0cv.com/wp-content/uploads/2025/07/image-44.png)
设置2个相机的视角,本文选择一个平行,一个垂直视角
![图片[10]-Unity3d Cinemachine篇(五)— ClearShot-灵码CV](https://www.0cv.com/wp-content/uploads/2025/07/image-45.png)
![图片[11]-Unity3d Cinemachine篇(五)— ClearShot-灵码CV](https://www.0cv.com/wp-content/uploads/2025/07/image-46.png)
并把2个相机的Collide Against设置成Obstacle
![图片[12]-Unity3d Cinemachine篇(五)— ClearShot-灵码CV](https://www.0cv.com/wp-content/uploads/2025/07/image-47.png)
4. 完成
![图片[13]-Unity3d Cinemachine篇(五)— ClearShot-灵码CV](https://www.0cv.com/wp-content/uploads/2025/07/1363cf45720e08507db58811f901eac1.gif)
© 版权声明
THE END
暂无评论内容