Hello, what im trying to do is change one object into another. for example how would i code for the DemoGameTile to turn into a Demon. Thanks in advance
using Instantiate : Unity - Scripting API: Object.Instantiate
and Destroy : Unity - Scripting API: Object.Destroy
using UnityEngine;
using System.Collections;
public class MonsterTrigger : MonoBehaviour {
public Transform demon;
public Transform goblin;
public Transform ogre;
private Transform clone;
void Start () {
}
void Update () {
}
void OnTriggerEnter(Collider other)
{
Vector3 clonePosition = new Vector3( 0.6096257f, 0.002073564f, -1.967801f );
switch( Random.Range(0, 4) )
{
case 0 :
clone = Instantiate( demon, clonePosition, Quaternion.identity) as Transform;
break;
case 1 :
clone = Instantiate( goblin, clonePosition, Quaternion.identity) as Transform;
break;
case 2 :
clone = Instantiate( goblin, clonePosition, Quaternion.identity) as Transform;
break;
case 3 :
clone = Instantiate( ogre, clonePosition, Quaternion.identity) as Transform;
break;
}
Destroy( gameObject );
}
}