using UnityEngine;
using System.Collections;
public class finish : MonoBehaviour {
void OnCollisionEnter (Collision col)
{
if(col.gameObject.name == "DeathCube1")
{
gameObject.AddComponent (Ctrl2);
}
}
}
Im trying to add my script Ctrl2 when deathcube1 touches this object
This script will attach Ctrl2 to the GamObject with OnCOllisionEnter script. Are u trying to attach Ctrl2 to DeathCube1? then use col.gameObject.AddComponent (Ctrl2);
– Priyanshu
– Inaetarucol.gameObject.AddComponent<Ctrl2>();