using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Experimental.VFX; public class EmitterController : MonoBehaviour { public bool debugMode = true; public bool randomWalk; public VisualEffect vfx; public GameObject baseEmitter; public GameObject target; public float growingSpeed = 0.002f; public Camera cam; float spawn_t; float total_t; float lerp_val; Vector3 final_pos; Transform target_trans; void Start() { spawn_t = 0; total_t = 0; //target_trans = target.GetComponent(); //cam = Camera.main; } // Update is called once per frame void Update() { Vector3 base_pos = baseEmitter.GetComponent().position; Vector3 target_pos = target.GetComponent().position; if (Input.GetMouseButton(0) == false) { lerp_val -= growingSpeed; } lerp_val = Mathf.Clamp(lerp_val, 0, 1); if(Input.GetMouseButton(0) == false && lerp_val == 0) { vfx.SendEvent("HasLeft"); } final_pos = Vector3.Lerp(base_pos, target_pos, lerp_val); transform.position = final_pos; if (Input.GetKeyDown(KeyCode.D)) { debugMode = !debugMode; baseEmitter.GetComponent().enabled = debugMode; target.GetComponent().enabled = debugMode; GetComponent().enabled = debugMode; } } private void OnMouseDown() { spawn_t = total_t; vfx.SendEvent("MouseDown"); //Debug.Log("Enter"); vfx.SetBool("_mouseDown", true); } private void OnMouseDrag() { total_t += Time.deltaTime; lerp_val += growingSpeed; vfx.SetFloat("_LerpVal", lerp_val); //vfx.SetBool("_mouseDown", true); } private void OnMouseUp() { //vfx.SendEvent("MouseUp"); vfx.SetBool("_mouseDown", false); } }