how to I randomly choose 1 of 3 spaceships for shooting? so far I didnt manage to choose the random spaceship object to shoot everytime in a different x axis
public void ShootProjectile()
{
firePoint.rotation = Quaternion.Euler(0, 0, 90);
if (projectilePrefab != null && firePoint != null)
{
// Instantiate the projectile at the firePoint's position and rotation
GameObject projectile = Instantiate(projectilePrefab, transform.position, firePoint.rotation);
// Optionally, apply velocity to the projectile for movement
Rigidbody2D rb = projectile.GetComponent<Rigidbody2D>();
if (rb != null)
{
rb.velocity = Vector2.left * 8f; // Adjust this speed as needed
}
}
}
ty