当动态改变cinemachine confiner的边界bound的时候,就会出现一个BUG。
当未运行场景前,cinemachine confiner设置的边界bounding shape 2D为一个值,当运行场景后,改变了这个 原始的bounding shape 2D的 Points数组,为一个不同的 四点坐标 边界,就会出现 cinemachine confiner 的边界 还是以 运行场景前,未改变 边界 的数组 为标准。
这样的话只是 动态改变 cinemachine confiner的bounding shape 2D 的points数组的边界,并没有 更新cinemachine confiner的bound 的points数组的值。
当 运行场景后,找到另外一个 含有组件Polygon Collider 2D的设置Is Trigger为False的对象 设置为 cinemachine confiner的bouding shape 2D 的对象。会发现 cinemachine confiner的bounding shape 2D的 摄像机 边界随之发生 改变。
设置Camera的组件CinemachineBrain的Default Blend为Hard Out
CM vcam的Cinemachine VirtualCamera的Body的Unlimited Soft Zone为真
CM vcam的Cinemachine confiner组件的Bounding Shape 2D为null
CM vcam的Cinemachine confiner组件的Dumping为0,则摄像机到达边界不会 往边界内反弹。
设置两个 PolygonCollider2D相互交替设置。
using UnityEngine;
using Cinemachine