{
void OnCollisionEnter (Collision col)
{
if(col.gameObject.name == "DeathCube1")
{
col.gameObject.RemoveComponent<Ctrl>();
}
}
}
Im trying to remove Ctrl from Deathcube1
{
void OnCollisionEnter (Collision col)
{
if(col.gameObject.name == "DeathCube1")
{
col.gameObject.RemoveComponent<Ctrl>();
}
}
}
Im trying to remove Ctrl from Deathcube1
The Destroy() method can be used to remove components or destroy GameObjects, depending what you pass it.
In your case:
Destroy(col.gameObject.GetComponent<Ctrl>());
As an aside, if you are trying to use Destroy in Gizmos code, you have to use DestroyImmediate() or Unity will simply warn you that destroying objects or components outside of play mode is dangerous - which is certainly true.
You could use the solution provided here but I suggest you disable it instead since it involves less overhead.