Raycast only hits object once

Hi all, I’m having a strange problem…

Basically, I want to cast a ray out to the cursor point, and then (do something) when the mouse clicks on an object with a certain tag.

I have two objects, ‘Origin’ and ‘Destination’, each tagged with ‘Origin’ and ‘Destination’ tags respectively.

The issue is, that it works fine the first time I click on each object, but doesn’t ever work again if I click on the object for a second time. I want it to continuously update no matter how many times I click on each object.

Here is the code in question:

		if (CurrentStatus == "Editing")
		{
			var EditingRay : Ray = MainCamera.ScreenPointToRay (Input.mousePosition);	
			var EditingRayHit : RaycastHit;	
			
			//Debug.DrawRay (EditingRay.origin, EditingRay.direction * 1000, Color.yellow);
			
			if (Physics.Raycast (EditingRay, EditingRayHit)) 				
			{		
				if (Input.GetMouseButtonDown(0)  EditingRayHit.collider.tag == "Origin")
				{
					print ("Origin!");
					//do editing here
				}
				if (Input.GetMouseButtonDown(0)  EditingRayHit.collider.tag == "Destination")
				{
					print ("Destination!");
					//do editing here
				}
				
			}
		}

It’s wrapped in the Update function, and the variable ‘CurrentStatus’ gets set to “Editing” prior to this part of the code (and doesn’t change).

Any idea why this might be happening?

To test it, I scrapped all the Input.GetMouseButtonDown(0) EditingRayHit.collider.tag == “x” if statements and replaced them with a simple print(EditingRayHit.transform.name), and it exhibited the same behavior - it would print the objects that the ray hit, but only once - if I returned my mouse to previously hit objects it wouldn’t print them again.

I’m a bit baffled, so any help would be much appreciated.

Mike

Turn off “collapse” in the console. Or if you’re using Unity 4, look at the counter on the right-hand side.

–Eric

So everything was working fine, just I had the wrong setting in the console?

Thanks Eric!