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.
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);
}
}