我很难在玩家面前放置一堵物体(箭头)。我想要的是在玩家面前垂直于视野射出一堵坚固的箭头墙。到目前为止,我的对象生成正确,y 轴放置正确。现在我只需要正确对齐 z 轴和 x 轴即可。我的代码如下:
void run()
{
Vector3 pos = transform.position;
Quaternion angle = transform.rotation;
GameObject clone;
float startx = pos.x;
pos.y += 0.7f;
pos.z += 2f;
for(int y = 0; y < maxarrows; y++)
{
pos.y += 0.5f;
for(int x = 0; x < maxarrows; x++)
{
pos.x -= 0.5f;
clone = arrowPool.getArrowOld();
if(clone != null)
{
clone.transform.position = pos;
clone.transform.rotation = angle;
clone.rigidbody.velocity = clone.transform.forward*force;
}
}
pos.x = startx;
}
}