我现在正在编写的武器系统,并希望在场景模式中看到我的雷CAST。 我按照教程做了所有的事情,但是仍然看不到它。
以下是相关代码:
void Update()
{
Shooting();
}
private void Shooting()
{
Ray ray = Cam.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));
RaycastHit hit;
Debug.DrawRay(ray.origin, ray.direction * range, Color.red);
if (Physics.Raycast(ray, out hit))
{
Debug.Log(hit.transform.name + hit.transform.position);
}
}
我在更新函数中调用的Shooting函数中建立了一个相机屏幕的射线,然后使用Debug的DrawRay函数绘制出射线到范围(range)以红色显示。
但是,我似乎还是看不到这个射线。
评论 (0)