Animation Problems when duplicating Object with Animation PLEASE HELP

So I have this bridge that is standing up vertically and if you point and click at it, it will fall down frontwards. If you click at it again while it is down it will go stand up vertically again.

What I want to do is duplicate the bridge in multiple places. However, when I duplicate one and try clicking on it, the bridge will go down but when I try clicking on it to go up again the bridge teleports or disappears into the original bridge I tried duplicating it from.

It’s pretty frustrating…

I have 2 codes for my Bridge

this one is attached to my bridge

var anim:boolean=false;

function Start()
{

}
function Update(){
var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (collider.Raycast (ray, hit, 1000)) {
Debug.DrawLine (ray.origin, hit.point);




if(Input.GetMouseButtonDown(0))
{
Wait();
}

} 
}

function Wait()
{
anim=!anim;
if(anim)
{
animation.CrossFade("BridgeOpen");
Debug.Log("Bridgeopen");
}
if(!anim)
{
animation.CrossFade("BridgeClose");
Debug.Log("Bridgeclose");
}

}

this one is not attached to my bridge

function Update () 
{
	// left clicky thing
	if(Input.GetMouseButtonDown(0))
	{
		//used to start our raycast into the 3d world
		var ray:Ray = Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
		
		//stores the object the ray hits in the Scene
		var hit:RaycastHit;
		
		//check if the ray collides with a Collider in the Scene
		if(Physics.Raycast(ray.origin,ray.direction,hit,Mathf.Infinity))
		{
			//if the ray collides with a Collider in the Scene
			Debug.Log(hit.transform.name); //print name of thing hit
			
			var bridge = hit.transform.GetComponent(Bridge); // Door is script name
			
			// if the Door script is attached to the object
			if(bridge)
			{
				// use public things (variables or functions)
				bridge.PlayBridgeAnimation();
			}
		}
	}
}

Sounds to me like you’ve got a global animation, which will always play using the global position values - which is why it jumps back to the original location versus a local animation, which will play the animation using the local position relative to a parent object.

If this is the case, you might want to try parenting the bridge, recording the animation, copying the parent/bridge, moving it, and then trying the animation.

but before I record the animation I must first make sure it is in local?

No, you shouldn’t have to do that. By parenting the bridge, the animation becomes local.

And the animation component is attached to the parent, not the bridge.

alright well my bridge is working but I have another object with animation. It’s my elevator lift. I click on my elevator and the elevator is supposed to go up, I click on it again and it’s suppose to go down. When I play the game and when I click on the elevator the elevator transports to some far out area of the map. When I click on the elevator while it is in the far out area of the map the animation works. I’m not sure of you’ve experienced this but do you know what to do if this happens?

Oh and this only happens when I parent the elevator

nvm got it