Im sure another simple question

Ok, I am on a roll. I have been researching this for the past couple hours and cant seem to get it exactly the way I want. As of right now I just want my enemies(floating cubes in the sky) to randomly shoot at the player. Seems simple enough, I just cant seem to figure it out.

As long as I am here I forsee the future already and I am going to want the “enemies” to re-spawn after they die. I will be researching this but thought if it was simple to add in and someone knew what I was talking about at least I asked :stuck_out_tongue:

Thank you again! I dont know where I would be without you guys!

Enemy script right now…

var boom : ParticleEmitter;

var smoke : ParticleEmitter;

function OnCollisionEnter () {

Destroy(gameObject);

Instantiate(boom, transform.position, transform.rotation);

	Instantiate(smoke, transform.position, transform.rotation);

}

I would go that way for the enemies :

  • Check if the player is visible every rnd seconds (rnd a random value picked every time). Use coroutines for that.
  • Get the vector enemy → player, normalize it. If the shoot is going to be slow, try forseeing the player movements.
  • Instantiate the bullet at the enemy’s position.
  • AddForce with the previous vector.
  • detect collision with player to do something (life–, anim, whatever)
  • Note that if the bullet is really fast, collision won’t be registered and you need to cast a ray.

Good luck !