浏览代码

Better laser graphic

/develop/cubewars/splashdamage
Ervin Teng 4 年前
当前提交
5bd9aa3a
共有 1 个文件被更改,包括 6 次插入5 次删除
  1. 11
      Project/Assets/ML-Agents/Examples/CubeWars/Scripts/Laser.cs

11
Project/Assets/ML-Agents/Examples/CubeWars/Scripts/Laser.cs


{
public bool isFired;
public float maxLength = 25f;
public float width = 0.5f;
public float width = 1f;
public bool animate = false;
LineRenderer laserRenderer;
// Start is called before the first frame update

laserRenderer.SetWidth(width, width);
laserRenderer.material.SetTextureScale("_MainTex", new Vector2(0.07f, 1.0f));
}

laserRenderer.SetWidth(width, width);
laserRenderer.material.SetTextureOffset("_MainTex", new Vector2(-3 * Time.time, 0.0f));
laserRenderer.material.SetTextureOffset("_MainTex", new Vector2(-6 * Time.time, 0.0f));
if (Physics.Raycast(transform.position, transform.forward, out hit, maxLength))
if (Physics.SphereCast(transform.position, width, transform.forward, out hit, maxLength))
laserRenderer.SetPosition(1, new Vector3(0f, 0f, hit.distance / transform.lossyScale.z));
float hitLength = Vector3.Distance(hit.point, transform.position);
laserRenderer.SetPosition(1, new Vector3(0f, 0f, hitLength / transform.lossyScale.z));
}
else
{

正在加载...
取消
保存