本文介绍了在Unity 2D中使用Physics.OverlapBox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Unity 2D进行游戏,我想在正方形区域中找到对象列表.该文档没有很好地解释;表示Physics.OverlapBox返回Collider[]Physics2D.OverlapBox返回bool.

I'm making a game with Unity 2D, I want to find a list of objects in a square area. The documentation didn't explain well; it says that Physics.OverlapBox returns Collider[] and Physics2D.OverlapBox returns bool.

我的问题是:

推荐答案

您需要使用 Physics2D.OverlapBox().

Physics特别是3D物理引擎,而Physics2D是所有2D物理引擎.他们不会互相对抗.

Physics is specifically the 3D physics engine and Physics2D is specificall the 2D physics engine. They do not work against each other.

这篇关于在Unity 2D中使用Physics.OverlapBox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 19:40