Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class SwordController : MonoBehaviour {
  5.  
  6. public float speed;
  7.  
  8. public PlayerController player;
  9.  
  10. public GameObject enemyDeathEffect;
  11. public GameObject impactEffect;
  12.  
  13. public int pointsForKill;
  14.  
  15.  
  16.  
  17. public int damageToGive;
  18.  
  19. // Use this for initialization
  20. void Start () {
  21. player = FindObjectOfType<PlayerController> ();
  22. }
  23.  
  24. // Update is called once per frame
  25. void Update () {
  26. transform.position = new Vector3 (player.firePoint.transform.position.x, player.firePoint.transform.position.y, player.transform.position.z);
  27. }
  28.  
  29. void OnTriggerEnter2D(Collider2D other){
  30. if (other.tag == "Enemy") {
  31. other.GetComponent<EnemyHealthManager>().giveDamage(damageToGive);
  32. }
  33. Instantiate(impactEffect, other.transform.position, other.transform.rotation);
  34. Destroy (gameObject);
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement