implement changes to game

This commit is contained in:
2026-05-26 11:48:51 +02:00
parent 8162e2b331
commit 8b88a9ca97
156 changed files with 7479 additions and 3905 deletions
+11 -1
View File
@@ -15,6 +15,7 @@ public class Bullet : MonoBehaviour
{
target = enemy.transform;
lastKnownDirection = (target.position - transform.position).normalized; // Store initial direction
UpdateRotation();
}
}
@@ -35,12 +36,21 @@ public class Bullet : MonoBehaviour
}
// Move bullet in the last known direction
UpdateRotation();
transform.position += (Vector3)lastKnownDirection * speed * Time.deltaTime;
// Destroy bullet after 5 seconds to prevent infinite movement
Destroy(gameObject, 5f);
}
void UpdateRotation()
{
if (lastKnownDirection.sqrMagnitude <= Mathf.Epsilon)
return;
transform.right = lastKnownDirection;
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Enemy"))
@@ -58,4 +68,4 @@ public class Bullet : MonoBehaviour
Instantiate(shatterEffectPrefab, transform.position, Quaternion.identity);
}
}
}
}