trying to make my enemy fall from sky and come towards me

Hi guys I was wondering if someone could help me out here, what I am trying to achieve is the following:

Enemy falls from the sky multiple instances(about 3 or 4 of them) and then shoots me while using the lookat function and moves towards me and I shoot back

So far this is for the enemy he looks at me and shoots but want him to fall from the Y axis (the sky) and also continue what its doing and move towards me:

function Update ()
{
if(LookAtTarget) // looking at the player
{
var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime * damp);

var seconds : int = Time.time; // whole number
var oddeven = (seconds % 2);

if(oddeven)
{
Shoot(seconds); // define shoot function
}
}

}

function Shoot(seconds) // now find enemy spawn and shoot at the player
{
if(seconds!=savedTime)
{

var bullet = Instantiate(bulletPrefab, GameObject.Find(“enemyspawn”).transform.position, Quaternion.identity);
bullet.rigidbody.AddForce(transform.forward * 1000);

savedTime = seconds;
}
}
I know I have to somehow create a variable and a function with and if statement but do know how I would go about it, any help would be great, tried to google it but don’t know how to put it into words to search for this question

Kindest regards
:wink:

okay I solved the first part I put the enemy in the sky along the y axis and added a rigidbody to it.

Please put code tags around your code to make it better readable. When you write a post, “go advanced” button.

sorry I didn’t realize my apologies Alex

Alex just a question I have managed to know get my enemy to come towards me and shoot and my enemy is a prefab, I have now added tow more enemy in the Y axis away from each other but when the fall from the sky they do not shoot do you have any idea why, I checked the look at Target in the inspector and noticed it was not looking at my player so I added it but still will not shoot, strange

Could be an easy reason. The falling prefab still have no rotation, would mean:

Enemy view ->>>>>>>>>>>>>>>> (looking straight, but the target is on the floor)
Target (floor)

Is your enemy script based on BurgZerg tutorial?

Next tip: edit your post instead doing a new posting :wink: