/// <summary> /// 显示path /// </summary> private void UpdateReference() { if (m_Power > 0.01f) { m_TrajectoryDir = m_TrajectoryDir.normalized; m_VerticalInitialVelocity = m_Power * Time.fixedDeltaTime * m_Rigi.mass; m_Hypotenuse = Mathf.Sqrt(m_TrajectoryDir.x * m_TrajectoryDir.x + m_TrajectoryDir.y * m_TrajectoryDir.y); //水平初速度 m_VerticalVelocity = m_TrajectoryDir.x / m_Hypotenuse * m_VerticalInitialVelocity; //处置初速度 m_VerticalEndVelocity = m_TrajectoryDir.y / m_Hypotenuse * m_VerticalInitialVelocity; float time = 0; for (int i = 0; i < MissilePath.ReferencePointCount; i++) { time += m_ReferenceTime; Vector2 pos = CalPos(time); GameObject go = MissilePath.GetReference(i); go.SetActive(true); go.transform.position = new Vector3(pos.x, pos.y, 0) + transform.position; go.transform.localScale = Vector3.one * ((1 - m_ReferencePointMinSize) * (1 - i / ((float)MissilePath.ReferencePointCount - 1)) + m_ReferencePointMinSize); } } else { MissilePath.ShowOrHideReference(false); } }
protected override void ShootEnter() { base.ShootEnter(); m_TrailRenderer.enabled = true; MissilePath.ShowOrHideReference(false); MissilePath.ShowOrHidePath(false); m_TrajectoryTimer = 0; m_PathTimer = 0; m_Rigi.constraints = RigidbodyConstraints2D.FreezeRotation; m_Rigi.velocity = new Vector2(m_VerticalVelocity, m_VerticalEndVelocity); IsTrajectory = true; if (OnShoot != null) { OnShoot(); } }