My Dumb question .Is it possible reuse an animated gameobject in the same scene?

I have created an animated bridge which opens and closes when the player stands on a switch. The bridge has animator controller and the switches have attached scripts to it.

I want to created few more bridges in the scene , but i understood you cant copy paste the bridge as its working gets messed up. So each time I have to duplicate the attached scripts(and edit the getcomponent names) , create new animation clips and animator controller to create a new working bridge each time.This is so time consuming !

Is there a easy method to just get this done . Please help me out .

Explain this part better - and someone can provide helpful feedback.
Are you using prefabs for all associated with the bridge?

1 Like

Sorry , I wasnt clear enough. No I am not using prefab. I made the animation clips of bridge opening and closing using unity animation, by moving the transform and setting key frames. So now i have these two animation clips + animator controller to control this animation clips ,and two scripts on the switches(switch to open and close the bridge) which will execute when the character stands on them . When I tried to copy paste a new bridge and the switches , when the player stand on any switch the 1st bridge open and closes not the new one.

It would be quite helpful if you could post the script that you are using to accomplish this. Without being able to see the script, it is difficult to figure out the problem. My guess is that you are using something like GameObject.Find(“Bridge”) which would be causing this type of problem. Please post your script and it will be much easier to help you out.

2 Likes

Thanks for the reply. I only wanted to know , in a scenario were you have to create multiple animated bridges(with there attached scripts) in scene, do you have to animate and build each bridge separately or just build one and do something like duplicate or copy paste. ? How to professional game developers do in this situation?

The switch will want to have a reference to the bridge that it controls, then when you detect that a switch is stood on it should inform the bridge that it controls to open (I would guess by setting a trigger on the animator component).

1 Like