[Unity]cinemachine confiner动态改变边界

在Unity中使用cinemachine confiner时遇到一个问题,即在运行场景前后动态改变bounding shape 2D的边界不生效。原因是cinemachine confiner的边界并未更新新的边界值。通过将含有Polygon Collider 2D组件且Is Trigger设为False的对象设置为cinemachine confiner的bounding shape 2D,可以实现边界动态更新。同时,设置CinemachineBrain的Default Blend为Hard Out,VirtualCamera的Body的Unlimited Soft Zone为真,Cinemachine confiner的Bounding Shape 2D为null,Dumping为0,可避免摄像机在边界处反弹。
摘要由CSDN通过智能技术生成

 

当动态改变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
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值