Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by WillCar8 · Aug 29, 2016 at 12:34 PM · instantiateprefabsarrays

Fill an array with prefabs?

alt text

alt text

I am trying to spawn random rocks at random spawn locations. I made the rocks into prefabs and tagged them as "Rocks". On start the Spawn Location array fills up. The RocksToSpawnClones array and the RocksToSpawnPrefabs array remain empty and no rock prefabs are spawned.

screen-shot-2016-08-28-at-32925-pm.png (17.1 kB)
screen-shot-2016-08-28-at-32949-pm.png (57.8 kB)
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 Landern · Aug 29, 2016 at 12:38 PM 1
Share

You stated you tagged them as "Rocks"

I made the rocks into prefabs and tagged them as "Rocks"

But you're looking for tags named "Rock" which wouldn't match against "Rocks" explicitly.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by TanselAltinel · Aug 29, 2016 at 12:40 PM

You are using GameObject.FindGameObjectsWithTag("Rock");

That method will only find objects in the active scene that is playing. However, you are saying that you have prefabs, which are physical files in your harddrive. This method won't find them (imagine looking for every directory and file, checking if it is a prefab and tagged as rocks).

What you need to do is to fill the rocksToSpawnPrefabs list manually in the editor screen. Surely, you have a game object with this script attached. See script field in the inspector, then drag and drop your prefabs to RocksToSpawnPrefabs list.

See this video for how it is done: https://www.youtube.com/watch?v=fxrgkw_QUGc Mind that, you need to drag your prefabs from your folder view to do that.

Comment
Add comment · Show 1 · 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 WillCar8 · Aug 29, 2016 at 08:57 PM 0
Share

Thanks! That worked

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Accessing variable of instantiated prefab inside array in javascript 1 Answer

Clicker game instantiate prefab depending on gold per click 0 Answers

Adding prefabs to a list or an array from a folder and instantiating them. 2 Answers

Instantiating Prefabs from a MonoBehaviour-derived class using an array -> compiling but not rendering [SOLVED] 0 Answers

Unity reading decimals 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