【发布时间】:2021-05-17 07:05:47
【问题描述】:
所以,游戏就是要找到不同。当射线击中隐藏对象的对撞机时,它应该只添加一个分数并将私有整数差异值减一。但是当光线撞击物体碰撞器时,它会在光线撞击碰撞器时不断增加/减少。我该如何改变呢?方法如下:
void Update()
{
camRay = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
Debug.DrawRay(camRay.origin, camRay.direction, Color.red, 1);
if (Input.touchCount > 0)
{
if (Physics.Raycast(camRay, out result))
{
/*{
obj = result.collider.gameObject;
score = score + 1;
differences= differences - 1;
score1.text = " " + score;
predmet.Play();
}*/
if (result.collider.CompareTag("Slike") && !hitOnce)
{
score +=1;
differences-= 1;
score1.text = " " + score;
predmet.Play();
}
else
{
hitOnce = false;
}
if (differences == 0)
{
WinPanel.SetActive(true);
}
}
}
}
【问题讨论】:
标签: c# android unity3d raycasting