我正在开发我的第一个Unity游戏,并且遇到此脚本的问题。Unity 5 - Physics.OverlapSphere无法正常工作
void FixedUpdate()
{
Debug.Log ("dead is " + dead);
dead = Physics.OverlapSphere (frontCheck.position, radius, whatIsWall);
if (dead == true)
{
Debug.Log ("Player died!");
Invoke ("Reset", 1);
}
}
void Reset()
{
SceneManager.LoadScene ("Game");
}
我想当玩家运行到墙上,使布尔dead
true,则使用在玩家面前的变换。我使用的是Physics2D.OverLapPoint,它运行良好,但我必须将玩家的物理学改为3D。我试图现在使用OverLapSphere,但我得到一个错误消息“不能隐式转换类型UnityEngine.Collider[]
到bool
。我该怎么做才能做到这一点?我非常初级Unity和编码,所以它可能是一个简单的修复。也许我只是需要尝试别的东西吗?谢谢。
这做到了!谢谢! – MayorDump