Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class EnemyShoot : MonoBehaviour {
- private float shotDelay= 1.0f;
- private float timer = 1.0f;
- private bool sh;
- public GameObject projectilePrefab;
- [SerializeField]
- protected Vector3 instantiationOffset = Vector3.zero;
- protected float damage = 1f;
- private void Update()
- {
- if(timer >= shotDelay)
- {
- timer = 0;
- GameObject projectile = Instantiate(projectilePrefab) as GameObject;
- projectile.transform.position = transform.position + instantiationOffset;
- projectile.SendMessage(Messages.ChangeDirection, new Vector2(Random.Range(-3.0f,0.0f), Random.Range(-1.0f,1.0f)), SendMessageOptions.DontRequireReceiver);
- }
- }
- private void OnCollisionEnter(Collision projectile){
- if(projectile.gameObject.tag == "Player")
- {
- //gameObject.SendMessage(Messages.Kill, SendMessageOptions.DontRequireReceiver);
- Debug.Log("Player");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement