unity3d - unity 忽略同一层上的碰撞

标签 unity3d

我想使用 Physics.IgnoreCollision 来避免子弹击中自己。
子弹在第 8 层生成。为什么这不起作用?你怎么能忽略与同一层上所有东西的碰撞?

// bulletscript.cs
gameObject.layer = 8;

// maingamescript.cs
Physics.IgnoreCollision(8,8);

第 8 层上可能还有其他对象也应该被忽略。
(例如,玩家飞船)。

最佳答案

为什么不使用方便的花花公子物理管理器。转到 Edit->Project Settings-> Physics 并设置适当的层碰撞。
enter image description here

关于unity3d - unity 忽略同一层上的碰撞,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38917858/

相关文章:

c# - 如何通过 out 参数将变量从 iOS native 代码返回到 C#?

unity3d - 编辑器窗口截图

c# - 如何在检查器中使用带有列表的 ReorderableList 并添加新的空项目和折叠子项?

javascript - 将 Unity WebGL 项目导入 Angular2 组件

c# - 如何以正确的方式加入 firebase 查询的结果

c# - GUIStyle.hover 状态是否适用于 Unity 编辑器标签(或除 Button 之外的其他控件)?

3d - 将 .ply 文件导入到 unity 3D

c# - System.Serializable 在 Unity 中的 List<MyClass> 上不起作用?

c# - 当以移动平台为 parent 时,角色移动缓慢

c# - 如何在 C# 中向 mailto 添加附件?