Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
1
Question by crynimar · May 24, 2012 at 09:39 PM · instantiateclone

how can i take reference to the clone and not to the Gameobject?

I have some GameObjects, and 2 of them are instatiate randomically, (it is a fight game) the AI, needs to know witch one is the main_character, well... the AI only look to the gameObject and not to this clone. (if i dont delete the gameobjec, the AI fight with the Game Object, but if there is only the clone, nothing rappens), please, help me XD, how can the AI see the clone (that will be instatiate)??

Comment
Add comment · Show 2
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 save · May 24, 2012 at 09:57 PM 0
Share

How is the AI selecting targets at the moment?

avatar image crynimar · May 24, 2012 at 09:59 PM 0
Share

public GameObject Personagem_Principal;
void Start() { Personagem_Principal = Rounds.Selecionado_aux; }

in Round.cs:

public static GameObject Selecionado_aux; Selecionado_aux=Personagens[0];

Personagens[0] is the original GameObject

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by appferreira · May 24, 2012 at 09:58 PM

Hello.

Im kinda new at unity, but as far as i know you can use TAGs to identify the prefab and then use a FOR LOOP to go throught each one, or as far as i know all clones without a defined name are called TheNameOfTheGameObject (Clone), so you can use that name, but i think might be better to use the for loop with tags.

See what more experienced ppl say about this.

Comment
Add comment · Show 2 · 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 crynimar · May 24, 2012 at 10:04 PM 0
Share

humm good idea, i think that i can try something whit tag... THX, i'll think in something... maybe will fix my bugs

avatar image aldonaletto · May 24, 2012 at 10:59 PM 0
Share

@appferreira's suggestion is ok: register a tag in the Inspector - "Inimigo", for instance - and set the enemy prefab tag to it: all enemies instantiated from this prefab will have the tag "Inimigo". When you destroy an enemy, you can use GameObject.FindWithTag("Inimigo") to find one of the remaining enemies alive:

  // when the enemy is destroyed, find a new one:
  if (!Selecionado_aux){ // if current enemy is dead...
    // find another one:
    Selecionado_aux = GameObject.FindWithTag("Inimigo");
  }

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Assigning gameobject to an instantiated prefab through script? 2 Answers

How to Instantiate and change velocity 2 Answers

How could I save all cloned objects in a scene, and load them back up on start? 1 Answer

Instantiating a GameObject from scene that changes 1 Answer

What can I do to make the objects I instantiated move with the background? 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