transform.rotate - Collision

I’m trying to do a really simple door opening script. Right now I have a cube (the door) in a GameObject (hinge). The hinge has a Hinge Joint attached and a spherical Spherical Collider. When the player enters the sphere, I would expect the hinge (and the door) to rotate. Here is my code…

 void  OnTriggerEnter ( Collider other  )
	{ 
		this.transform.Rotate(Vector3.up,Time.deltaTime); 
      }

I looked and there were a number of complicated solutions. But It seems like this would work, but it doesn’t. Any ideas? Thanks.

Your code only gets called once, when an object enters a trigger area.

Maybe try something like this:

   bool opening = false;

   void  OnTriggerEnter ( Collider other  )
   { 
      opening = true 
   }

   void Update ()
   {
      if(opening) {
         this.transform.Rotate(Vector3.up,Time.deltaTime);
         if (CheckToSeeIfThisIsFullyOpened ()) {
            opening = false;
         }
      }
   }