Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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

Discussion in 'Animation' started by ashc91, Feb 18, 2017.

  1. ashc91

    ashc91

    Joined:
    Aug 27, 2016
    Posts:
    41
    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 .
     
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Explain this part better - and someone can provide helpful feedback.
    Are you using prefabs for all associated with the bridge?
     
    ashc91 likes this.
  3. ashc91

    ashc91

    Joined:
    Aug 27, 2016
    Posts:
    41

    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.
     
  4. TrickyHandz

    TrickyHandz

    Joined:
    Jul 23, 2010
    Posts:
    196
    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.
     
    ashc91 and theANMATOR2b like this.
  5. ashc91

    ashc91

    Joined:
    Aug 27, 2016
    Posts:
    41

    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?
     
  6. NeilW

    NeilW

    Joined:
    May 29, 2014
    Posts:
    40
    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).
     
    theANMATOR2b likes this.