Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Jan 29, 2015 at 01:15 PM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
7
Question by Tabu · Sep 25, 2010 at 02:45 PM · instantiatenamerename

Remove (clone) from Instantiated Gameobjects name

I am looking for a way to not have an instantiated gameobject carry the (clone) after its name.

Right now I add two prefabs to viking1 and viking2. but no matter how i do it in the script that Instantiates,the name of the gameobjects always have the (Clone) after its name. Once its instantiated.

If I set the name in the GameObjects script, it will rename it correctly, but thats not a real option, since several gameobjects use this same script.

public class ControllerScript : MonoBehaviour { public GameObject viking1; public GameObject viking2;

 void Awake()
 {
     Vector3 pos = transform.position;
     pos.x = transform.position.x + 2;
     Instantiate(viking1, pos, Quaternion.identity); //Instantiating Viking1.

     pos.x = transform.position.x - 2;
     Instantiate(viking2, pos, Quaternion.identity); //Instantiating Viking2.

 }
 // Use this for initialization
 void Start () {
     viking2.name = "Viking2";
     viking1.name = "Viking1";
 }}

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ReubenX · Nov 16, 2015 at 01:23 PM 0
Share

Not sure how to do a C# script but for JS script you can try this:

var viking = Instantiate(viking1, pos, Quaternion.identity); viking.name = "Viking2";

2 Replies

  • Sort: 
avatar image
23
Best Answer

Answer by Mike 3 · Sep 25, 2010 at 02:58 PM

You need to set the name of the instantiated gameobject, not the two items you're using to instantiate.

e.g.

GameObject newViking1 = (GameObject)Instantiate(viking1, pos, Quaternion.identity); //Instantiating Viking1.
newViking1.name = viking1.name;
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Tabu · Sep 25, 2010 at 06:10 PM 0
Share

Perfect, this solved my problem, I dont know why I did not think of this.. Am a bit new to program$$anonymous$$g, thats probably why ;) Thanks again

avatar image devstudents · Nov 03, 2014 at 03:34 AM 0
Share

It still doesn't work for me. Debug says that the name is 3 but the inspector says it's 3(clone) which is why I still cannot convert it to an integer.

avatar image meat5000 ♦ · Jan 29, 2015 at 01:15 PM 0
Share

It probably means you are not referencing the correct object @mattockman

avatar image
2

Answer by Tabu · Sep 25, 2010 at 06:11 PM

Here is the working code:

void Awake() { Vector3 pos = transform.position; pos.x = transform.position.x + 2; GameObject newViking1 = (GameObject)Instantiate(viking1, pos, Quaternion.identity); //Instantiating Viking1. newViking1.name = "Viking1";

 pos.x = transform.position.x - 2;
 GameObject newViking2 = (GameObject)Instantiate(viking2, pos, Quaternion.identity); //Instantiating Viking2.
 newViking2.name = "Viking2";

}

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Assign Names Problem 1 Answer

Instantiate Name Issue. 1 Answer

Get instantiated name even before loading the asset from bundle 0 Answers

Naming Instantiated Prefabs 2 Answers

Renaming Child Objects during Instantiate? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges