Синтаксис:
Используется csharp
private void BombDropPos()
{
//Debug.Log($"{transform.position.x } 0, {transform.position.z + speed * bombFlyTime}");
bombDropPos = new Vector3(transform.position.x, 0, transform.position.z + speed * (bombFlyTime + maxInterval * bombsSP.Count));
}
private void CheckTarget()
{
RaycastHit hit;
Ray ray = new Ray(transform.position, -transform.position + bombDropPos);
Debug.DrawRay(transform.position, -transform.position + bombDropPos, Color.red);
if (Physics.Raycast(ray, out hit, 100f/*Mathf.Sqrt(speed * speed * (bombFlyTime + maxInterval * bombsSP.Count) * (bombFlyTime + maxInterval * bombsSP.Count) + flyHeight * flyHeight)*/))
{
if (hit.collider.GetComponent<Building>() != null)
{
Debug.Log("Detected!");
onTarget = true;
}
}
else
return;
}
{
//Debug.Log($"{transform.position.x } 0, {transform.position.z + speed * bombFlyTime}");
bombDropPos = new Vector3(transform.position.x, 0, transform.position.z + speed * (bombFlyTime + maxInterval * bombsSP.Count));
}
private void CheckTarget()
{
RaycastHit hit;
Ray ray = new Ray(transform.position, -transform.position + bombDropPos);
Debug.DrawRay(transform.position, -transform.position + bombDropPos, Color.red);
if (Physics.Raycast(ray, out hit, 100f/*Mathf.Sqrt(speed * speed * (bombFlyTime + maxInterval * bombsSP.Count) * (bombFlyTime + maxInterval * bombsSP.Count) + flyHeight * flyHeight)*/))
{
if (hit.collider.GetComponent<Building>() != null)
{
Debug.Log("Detected!");
onTarget = true;
}
}
else
return;
}
Буду благодарен за любой совет! (Если это важно.Самолет несет 4 бомбы и сбрасывает их с интервалом 0.25 секунд. Поэтому я ко времени полета прибавляю время самого сброса (maxInterval*bombsSP.Count))