- Home /
How Change one object to another in animation? ( change Sphere to cube)
Hi people. I am new in game development . So I am trying to change Sphere to Cube during the animation I wrote this code, but it has lots of problems and I can't find mistakes . I create one empty object as a parent and cube and sphere as a circle . I don't know its right or not also in all of them add this script. And it does not work . Could U help me plz ? using UnityEngine; using System.Collections;
public class Replaceobjects : MonoBehaviour {
public Transform Sphere;
public Transform Cube;
private Transform clone;
void Start () {
}
void Update () {
}
{
Vector3 clonePosition = new Vector3( 0.6096257f, 0.002073564f, -1.967801f );
switch( Random.Range(0, 2) )
{
case 0 :
clone = Instantiate( Sphere, clonePosition, Quaternion.identity) as Transform;
break;
case 1 :
clone = Instantiate( Cube, clonePosition, Quaternion.identity) as Transform;
break;
}
Destroy( gameObject );
}
}
Comment