This commit is contained in:
MrTorex committed 2026-03-01 00:29:25 +03:00
1 parent bca661e132
commit ed0437638b
9 files changed
+3442 -17

No files matched your search

+7 -7
View File
@@ -66,7 +66,7 @@ namespace Code.Lab5
private void TryFireAtTarget()
{
if (!wanderingTarget || !projectilePrefab) return;
if (wanderingTarget == null || projectilePrefab == null) return;
var targetPos = wanderingTarget.transform.position;
var targetVelocity = GetTargetVelocity();
@@ -99,10 +99,10 @@ namespace Code.Lab5
private Vector3 GetTargetVelocity()
{
if (wanderingTarget) return Vector3.zero;
if (wanderingTarget == null) return Vector3.zero;
var targetAgent = wanderingTarget.GetComponent<Agent>();
if (targetAgent)
if (targetAgent != null)
{
return targetAgent.velocity;
}
@@ -166,7 +166,7 @@ namespace Code.Lab5
var projectile = projObj.GetComponent<Projectile>();
projectile.Set(transform.position, direction, launchSpeed);
if (showPredictedPosition && targetCirclePrefab)
if (showPredictedPosition && targetCirclePrefab != null)
{
SpawnTargetCircle(targetPos, "ShotTarget");
}
@@ -174,7 +174,7 @@ namespace Code.Lab5
private void UpdatePredictedTargetVisual()
{
if (wanderingTarget) return;
if (wanderingTarget == null) return;
var targetPos = wanderingTarget.transform.position;
var targetVelocity = GetTargetVelocity();
@@ -187,10 +187,10 @@ namespace Code.Lab5
Debug.DrawLine(targetPos, predictedPos, Color.yellow);
}
private void SpawnTargetCircle(Vector3 position, string name1 = "TargetCircle")
private void SpawnTargetCircle(Vector3 position, string name = "TargetCircle")
{
var circle = Instantiate(targetCirclePrefab, position, Quaternion.identity);
circle.name = name1;
circle.name = name;
var circlePos = circle.transform.position;
circlePos.y = 0.05f;