You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.0 KiB
82 lines
2.0 KiB
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<Transform>();
|
|
//cam = Camera.main;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
Vector3 base_pos = baseEmitter.GetComponent<Transform>().position;
|
|
Vector3 target_pos = target.GetComponent<Transform>().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<Renderer>().enabled = debugMode;
|
|
target.GetComponent<Renderer>().enabled = debugMode;
|
|
GetComponent<Renderer>().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);
|
|
}
|
|
|
|
|
|
}
|
|
|