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