SendMessage getting "stuck" / looping animation, not returning to Update

I have a scenario where I have an animation attached to an object (a door that opens), and when I look at the door, I want to trigger the animation (I do not want to do this with an event/collision trigger for certain reasons)

So I am raycasting in my Camera’s Update, and when I hit an object tagged “door”, I use:

hitTransform.parent.SendMessage("UseDoor");

which calls…

var opened : int;
 
function UseDoor () {
 
if (opened) {
gameObject.GetComponent(Animation).Play("Close");
GetComponents(AudioSource)[1].Play();
} else {
gameObject.GetComponent(Animation).Play("Open");
GetComponents(AudioSource)[0].Play();
}  
 
   
} // end UseDoor

(yes, I’m working in two different script languages here… would that affect anything? I have some assets/packages that use .js, but I always use C#)

So, what happens is, this successfully triggers the door to open… but it gets stuck on that, and continuously loops the opening animation, while not returning to Update on the camera to allow for further processing.

Anybody know why it would get “stuck” like this and not return control to Update?

PS. I call the SendMessage in Update if a 2 second timer has run down to <= 0, ie. if you look at the door for 2 seconds, like this:

if (action != "") {
			if (action == "walk") {
				MoveTowardsTarget(hitPoint);
			}
			else if (action == "usedoor") {
				// Trigger the door script on the door
				timer = _resettime; // _resettime is 2.0f seconds
				hitTransform.parent.SendMessage("UseDoor");
				currChoice = "";
			}
			else if (action == "grab") {
				// Walk toward item and pick it up
			}

		}

		else if (Physics.Raycast (transform.position, fwd, out hit, rayCastDistance)) {

The Message gets sent, but it doesn’t reset timer, reset selection, or move into the raycasting portion to check for new input…

I think that :

  • You look forward the door
  • You check if the door is in front of you by raycasting
  • So you send a message to open the door
  • You still in front of the door so it continue to send message and so never reset.

Did you put a stop condition after open the door to not interact again with it ?