I get this message:
Type UnityEngine.Collider' does not contain a definition for
enabled’ and no extension method enabled' of type
UnityEngine.Collider’ could be found (are you missing a using directive or an assembly reference?)
But I see “enabled” here:
What am I missing? Shouldn’t I be able to set it? The link here: Unity - Scripting API: Collider.enabled even shows me how to do it, but it won’t let me…
CODE
public void OnTriggerEnter(Collider other)
{
// Do no collide with yourself
if (other.name == transform.parent.name)
return;
// Snap to the X of this box
Vector3 tmpPos = other.transform.position;
tmpPos.x = transform.position.x;
tmpPos.x = 0; print(tmpPos + " " + other.transform.position);
other.enabled = false;
other.transform.position = tmpPos;
print(other.name);
}
Any help you can give would be great. Thanks in advance.