Code weiter unten :
nach langer zeit kommen jetzt wieder tutorials hier ein dissolve laiser beim
nesten mal kommt warscheinlich leitern und wände klättern
bei ideen einfach in die kommentare hier der code
da spitzeklammern nicht erlaubt sind ersätze ich sie durch ein k für kleinerr als und ein g für größer als nicht verwirren lassen
Unity tutorial playlist :
• Unity Tutorials
OpenEyes Assets :
Low poly Medial pack : https://opengameart.org/content/opene...
CODE ;
public class hitDisslove : MonoBehaviour
{
public Camera cam;
public GameObject particle;
Vector2 pixelUV;
Texture2D tt;
Renderer rend;
RaycastHit hit;
public ParticleSystem p;
public int cmax, count, Power;
private float range,x,y;
public float repat, min, max;
void Update()
{
if (Input.GetMouseButton(0))
{
p.Play();
if (!Physics.Raycast(cam.ScreenPointToRay(Input.mousePosition), out hit))
return;
p.transform.LookAt(hit.point);
rend = hit.transform.GetComponentkRendererg();
try
{
if (rend.material.GetTexture("Texture2D_FAB93C5A") == null) return;
tt = new Texture2D(rend.material.GetTexture("Texture2D_FAB93C5A").width, rend.material.GetTexture("Texture2D_FAB93C5A").height);
Graphics.CopyTexture(rend.material.GetTexture("Texture2D_FAB93C5A") as Texture2D, tt);
pixelUV = hit.textureCoord;
pixelUV.x *= tt.width;
pixelUV.y *= tt.height;
count = 0;
CancelInvoke();
StartCoroutine(diss(new Vector2(pixelUV.x, pixelUV.y)));
}catch(System.Exception )
{
}
}
else
{
p.Stop();
}
if (count g cmax) CancelInvoke();
}
IEnumerator diss(Vector2 v)
{
Vector2 v2 = v;
range = Power + Random.Range(0, 20);
if (Random.value g .5f)
{
v2.x += Random.Range(1, 10);
v2.y += Random.Range(1, 10);
}
else
{
v2.x -= Random.Range(0, 12);
v2.y -= Random.Range(0, 12);
}
x = v2.x;
y = v2.y;
Circle(x, y, range, Color.black);
InvokeRepeating("set1", 0.1f, repat);
yield break;
}
void set1()
{
count++;
range += Random.Range(min, max);
Circle(x, y, range, Color.black);
}
void Circle(float x, float y, float r, Color color)
{
float rSquared = r * r;
for (int u = 0; u k tt.width; u++)
{
for (int v = 0; v k tt.height; v++)
{
if ((x - u) * (x - u) + (y - v) * (y - v) k rSquared)
{
tt.SetPixel(u, v, color);
}
}
}
tt.Apply();
rend.material.SetTexture("Texture2D_FAB93C5A", tt);
}
}