- Home /
How to show the flash effect in Unity
I am Unity beginner. Here is a flash link. link text
You can set the limit of split.
and touch the square that start to split.
Square split to the limit you set will restore to origin square.
I don't have a idea how to show effect like this in Unity.
Someone can give a hint?
Just letting you know that we don't give scripts here. We won't write you a full script (unless someone got generous).
So what I think he did is used animations to split them and then reversed the animation.
Because it can adjust the limit from 32 to 512. If I recorded the video, I must record 480 video,right?
Answer by DaveA · Jun 13, 2013 at 03:40 PM
This looks like it was done by program, not animation. Probably a fractal. Google 'fractals' to see how that's done (hint: probably 'recursion'). So he splits the one object (square) into two or more new objects (rectangles). He applies some animation code (translation) to each of those objects to move them apart. He turns off rendering the original object. Then pauses, then repeats the process on the new pieces. Does that X number of times, where X is 32 to 512.
By the way, in Unity it would be just as easy to do this in 3D rather than 2D for even cooler effect
Answer by Staln · Jun 15, 2013 at 10:38 AM
I want to show flash fission effect. I let cube object to instantiate two prefab and hide itself. And wait 2 sec, each prefab create two prefab again and hide itself. The created object can smoothly separate at first, but second time fission the created object reach end point rapidly .
I no idea where is going wrong?
#pragma strict
var myObject:GameObject;
static var totalNum:int=1;
private var fission1:GameObject;
private var fission2:GameObject;
private var fission1Vector3:Vector3;
private var fission2Vector3:Vector3;
private var parentHide:boolean=false;
private var locHorDirection:boolean;// Apart direction
private static var horDirection:boolean=false;//// Apart direction
private static var fissionTime:float=0;
private static var isFirst:boolean=true;
function Start () {
if(!isFirst)
{
yield WaitForSeconds(2);
}
isFirst=false;
Debug.Log(this.gameObject.name);
if(!parentHide&&totalNum<4)
{
if(horDirection)
{
var randX:int=Random.Range(1, 9);
var parentX:float=renderer.bounds.size.x;
fission1Vector3=transform.position;
fission2Vector3=transform.position;
fission1Vector3.x+= parentX*0.25;//(parentX*(randX/10.0))*(parentX*(randX/10.0));
fission2Vector3.x-= parentX*0.25;//(parentX*((10-randX)/10.0))*(parentX*((10-randX)/10.0));
fission1= Instantiate(myObject,fission1Vector3, Quaternion.identity);
fission2= Instantiate(myObject,fission2Vector3, Quaternion.identity);
fission1.transform.localScale.x*=0.5;//(randX/10.0);
fission2.transform.localScale.x*=0.5;//((10-randX)/10.0);
// fission1.transform.position=fission1Vector3;
// fission2.transform.position=fission2Vector3;
totalNum++;
renderer.enabled=false;
parentHide=false;
locHorDirection=horDirection;
if ((totalNum & totalNum - 1) == 0)//determine if 2's power
{
horDirection=!horDirection;
fissionTime++;
}
}
else
{
var randY:int=Random.Range(1, 9);
var parentY:float=renderer.bounds.size.y;
fission1Vector3=transform.position;
fission2Vector3=transform.position;
fission1Vector3.y+= parentY*0.25;//(parentX*(randX/10.0))*(parentX*(randX/10.0));
fission2Vector3.y-= parentY*0.25;//(parentX*((10-randX)/10.0))*(parentX*((10-randX)/10.0));
fission1= Instantiate(myObject,fission1Vector3, Quaternion.identity);
fission2= Instantiate(myObject,fission2Vector3, Quaternion.identity);
fission1.transform.localScale.y*=0.5;//(randX/10.0);
fission2.transform.localScale.y*=0.5;//((10-randX)/10.0);
// fission1.transform.position=fission1Vector3;
// fission2.transform.position=fission2Vector3;
totalNum++;
renderer.enabled=false;
locHorDirection=horDirection;
if ((totalNum & totalNum - 1) == 0) //determine if 2's power
{
horDirection=!horDirection;
fissionTime++;
}
}
}
}
function Update () {
if(locHorDirection)
{
if(fission1!=null)
fission1.transform.position=Vector3.Lerp(transform.position,fission1Vector3+Mathf.Pow(0.8,fissionTime)*Vector3(1.0,0,0),Time.time);
if(fission2!=null)
fission2.transform.position=Vector3.Lerp(transform.position,fission2Vector3+Mathf.Pow(0.8,fissionTime)*Vector3(-1.0,0,0),Time.time);
}
else
{
if(fission1!=null)
fission1.transform.position=Vector3.Lerp(transform.position,fission1Vector3+Mathf.Pow(0.8,fissionTime)*Vector3(0,1.0,0),Time.time);
if(fission2!=null)
fission2.transform.position=Vector3.Lerp(transform.position,fission2Vector3+Mathf.Pow(0.8,fissionTime)*Vector3(0,-1.0,0),Time.time);
}
}