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 PlayerSpells : MonoBehaviour {
- bool moveTowards = false;
- GameObject FIREBALL;
- Vector3 point;
- [Header("Spell Effects Objects")]
- public GameObject PS_HEALINGPAD;
- public GameObject PS_FIREBALL;
- public enum spellType
- {
- Heal,
- Single,
- Area,
- Link
- }
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- if (Input.GetKeyDown(KeyCode.E))
- {
- Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2.0f, Screen.height / 2.0f, 0));
- RaycastHit hit;
- if (Physics.Raycast(ray, out hit, 200))
- {
- point = hit.point;
- StartCoroutine("fish");
- }
- }
- }
- IEnumerator fish()
- {
- GameObject player = GameObject.Find("FPSController");
- GameObject FIREBALL = Instantiate(PS_FIREBALL, player.transform.position, Quaternion.identity);
- //FIREBALL.transform.SetParent(player.transform);
- yield return new WaitForSeconds(2.5f);
- moveTowards = true;
- moveBall(FIREBALL);
- yield return null;
- }
- void moveBall(GameObject FIREBALL)
- {
- if (moveTowards == true)
- {
- if(FIREBALL.transform.position != point)
- {
- Debug.Log("I hit: " + point);
- Debug.Log(moveTowards);
- FIREBALL.transform.position = Vector3.MoveTowards(FIREBALL.transform.position, point, Time.deltaTime * 5);
- Debug.Log(FIREBALL);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement