48 lines
997 B
C#
48 lines
997 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ShockwaveShaderHelper : MonoBehaviour
|
|
{
|
|
|
|
public Material mat;
|
|
// public Material _mat;
|
|
public Transform target;
|
|
|
|
public Vector2 offset;
|
|
public Vector2 screenOnPos;
|
|
|
|
public bool started = false;
|
|
public float speed = 1f;
|
|
public float val = 1f;
|
|
|
|
private void Awake()
|
|
{
|
|
// _mat = new Material(mat);
|
|
// GetComponent<SpriteRenderer>().material = _mat;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
screenOnPos = Camera.main.WorldToViewportPoint(target.position);
|
|
mat.SetVector("_RingSpawnPosition", offset + screenOnPos);
|
|
|
|
if(val < 1)
|
|
{
|
|
val += Time.deltaTime * speed;
|
|
}
|
|
mat.SetFloat("_WaveDistanceFromCenter", val );
|
|
|
|
|
|
/* if(_mat.GetFloat("_WaveDistanceFromCenter") >= 1f)
|
|
{
|
|
Destroy(gameObject);
|
|
}*/
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
val = 0.087f;
|
|
}
|
|
}
|