Greetings to all? Please tell me how to make enemies randomly emitted along the axis of X? May have any examples?
There is such a script, but it is in JavaScript. Please tell me how to convert a C Sharp and do outreach enemies along the X axis from left to right
public var enemy : GameObject;
public var spawnTime : float = 2;
function Start() {
InvokeRepeating("addEnemy", spawnTime, spawnTime);
}
// New function to spawn an enemy
function addEnemy() {
var x1 = transform.position.x - renderer.bounds.size.x/2;
var x2 = transform.position.x + renderer.bounds.size.x/2;
var spawnPoint = new Vector2(Random.Range(x1, x2), transform.position.y);
Instantiate(enemy, spawnPoint, Quaternion.identity);
}