Advertisement
Guest User

sss

a guest
Nov 23rd, 2014
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. public class EnemyShoot : MonoBehaviour {
  2.  
  3. private float shotDelay= 1.0f;
  4. private float timer = 1.0f;
  5.  
  6. private bool sh;
  7.  
  8. public GameObject projectilePrefab;
  9.  
  10. [SerializeField]
  11. protected Vector3 instantiationOffset = Vector3.zero;
  12.  
  13. protected float damage = 1f;
  14.  
  15. private void Update()
  16. {
  17.  
  18. if(timer >= shotDelay)
  19. {
  20. timer = 0;
  21. GameObject projectile = Instantiate(projectilePrefab) as GameObject;
  22. projectile.transform.position = transform.position + instantiationOffset;
  23. projectile.SendMessage(Messages.ChangeDirection, new Vector2(Random.Range(-3.0f,0.0f), Random.Range(-1.0f,1.0f)), SendMessageOptions.DontRequireReceiver);
  24. }
  25. }
  26.  
  27. private void OnCollisionEnter(Collision projectile){
  28.  
  29. if(projectile.gameObject.tag == "Player")
  30.  
  31. {
  32. //gameObject.SendMessage(Messages.Kill, SendMessageOptions.DontRequireReceiver);
  33. Debug.Log("Player");
  34. }
  35.  
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement