Ontrigger gameobject rescale

Is there a way wherein i could change the scale of a transform when it collide on a trigger?

I’m using this script right now but it doesn’t take effect

 
var sphere : Transform;
function OnTriggerEnter(other : Collider)
{
  if (other.gameObject.tag == "Maximize")
  {
    sphere.localScale += Vector3(2,2,2);
  }
}

I suspect you’re attaching this script to the wrong object: this code should be attached to the sphere or to the trigger object. If attached to the sphere, the variable sphere would not be necessary:

function OnTriggerEnter(other : Collider)
{
  if (other.tag == "Maximize") // collider has direct access to tag
  {
    transform.localScale += Vector3(2,2,2);
  }
}

If it still doesn’t work, follow the trigger check list:

  • The trigger object’s collider must have Is Trigger set;

  • The sphere or the trigger must be a rigidbody or CharacterController;

  • Triggers detect when an object enters or exit, but objects created or teleported inside it aren’t detected;

  • Triggers too thin may fail to detect CharacterControllers;