Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class MagicArrow : MonoBehaviour
- {
- // Start is called before the first frame update
- public GameObject prefab;
- public GameObject prefabCast;
- public float shootCooldown = 0.2f;
- public float shootTimer = -1.0f;
- private GameObject target;
- private ParticleSystem Effect;
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.Alpha1))
- {
- ShootMagic();
- }
- }
- void ShootMagic()
- {
- for(int i = 0; i < 5; i++)
- {
- GameObject projectile = Instantiate(prefabCast, transform.position, transform.rotation);
- target = GameObject.FindGameObjectWithTag("Enemy") ?? null;
- if (target != null)
- {
- projectile.GetComponent<TargetProjectile>().UpdateTarget(target.transform, Vector3.zero);
- Effect = prefab.GetComponent<ParticleSystem>();
- Effect.Play();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement