Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
Physics.IgnoreCollision 忽略碰撞
# [Physics](Physics.html).IgnoreCollision 忽略碰撞 static function *IgnoreCollision* (*collider1* : [Collider](../Collider/Collider.html), *collider2* : [Collider](../Collider/Collider.html), *ignore* : bool = true) : void *Description* 描述 Makes the collision detection system ignore all collisions between collider1 and collider2. 使碰撞体 1 和碰撞体 2 的碰撞侦测无效。 This is most useful for making eg. projectiles not collide with the object shooting them. 如果要忽略炮弹和发射物之间的碰撞侦测,这种情况下是很有用的。 IgnoreCollision has a few limitations: 1) It is not persistent. This means ignore collision state will not be stored in the editor when saving a scene. 2) You can only apply the ignore collision to colliders in active game objects. When deactivating the collider or attached rigidbody the IgnoreCollision state will be lost and you have to call [Physics.IgnoreCollision](Physics.IgnoreCollision.html) again. 忽略碰撞情况下的限制:1. 保存场景时忽略状态不能保存。2.只能在活动的对象物体上应用。如果用在失效的物体上,必须要调用一次 physics.IgnoreCollision. 参见: [Physics.IgnoreLayerCollision](Physics.IgnoreLayerCollision.html) * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { public Transform bulletPrefab; void Start() { Transform bullet = Instantiate(bulletPrefab) as Transform; Physics.IgnoreCollision(bullet.collider, collider); } } ``` ``` // Instantiate a bullet and make it ignore collisions with this object. // 实例化一个子弹,忽略与发射体的碰撞。 var bulletPrefab : Transform; function Start () { var bullet = Instantiate(bulletPrefab) as Transform; Physics.IgnoreCollision(bullet.collider, collider); } ```
da
2022年5月23日 14:19
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码