Hello,
I am working on a
- Side scroller ( meant that the view is 2D) - only on X-Y plane. Z always ‘0’.
- The canon has to be placed on the left most corner and fire in a Projectile Fashion
Game Objects :
I have placed a script called as “enemypos” on an empty gameobject. Then there is another prefab called as the “enemy” which is the enemy.
Code:
The enemypos script is as follows :
var projscript : projectile;
var ene_pos: Transform;
var pos : float;
function Awake()
{
e_spawn();
}
function Update ()
{
}
function e_spawn()
{
pos = projscript.spawn();
var position: Vector3 = Vector3(pos, 1, 0);
var enemy = Instantiate(ene_pos, position, Quaternion.identity);
}
The spawn() function is as follows: (is called from another script)
function spawn()
{
if(Random.Range(0,10)<7)
return Random.Range(-18,10);
else
return Random.Range(10,21);
}
Code Explanation:
The function e_spawn() is used to instantiate the enemy prefab.
Request:
My humble request is how to destroy and instantiate the same enemy along the x axis.
THANK YOU in advance