Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class SwordController : MonoBehaviour {
- public float speed;
- public PlayerController player;
- public GameObject enemyDeathEffect;
- public GameObject impactEffect;
- public int pointsForKill;
- public int damageToGive;
- // Use this for initialization
- void Start () {
- player = FindObjectOfType<PlayerController> ();
- }
- // Update is called once per frame
- void Update () {
- transform.position = new Vector3 (player.firePoint.transform.position.x, player.firePoint.transform.position.y, player.transform.position.z);
- }
- void OnTriggerEnter2D(Collider2D other){
- if (other.tag == "Enemy") {
- other.GetComponent<EnemyHealthManager>().giveDamage(damageToGive);
- }
- Instantiate(impactEffect, other.transform.position, other.transform.rotation);
- Destroy (gameObject);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement