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 FuryFight3r · Mar 15, 2017 at 11:10 PM · gameobjectpositioninstantiate prefablocation

Instantiating Multiple Game Objects to the Position of a Current GameObject

Hey guys, Take this how you will, but I'm making a game that concludes of Marijuana Growth, i have everything working to a standard, from adding the soil to planting the seed, and even the tree growth, and the ability to harvest it once grown, but what i want, is when i harvest the plant, it spawns new objects (More seeds to plant (X2 to be exact so the growth doubles)) and a Block of Marijuana that is Sell-able, i have both the Prefabs for the Seeds and the Block, i have somewhat of an idea how to Instantiate Objects, i also have a current object in the game called HarvestSpawn (which is just a box collider that i hope to use as the spawn position for the items harvested, but they spawn at the very corner of the map in the edge of the game canvas.. Eg. 0 x 0 x 0 on the worlds map, Whereas my HarvestSpawn Object location is 114 x 80 x 373 which is where i would like my Harvested Objects to spawn, i also have a Parent that i would like these Instantiated objects to go, under the 'iObjects' GameObject in the main hierarchy, this is what i use for all my 'Intractable Objects'.... i have provided a short video, to better help for a solution to this issue I'm having, as i see a lot of people asking these questions and never getting the questions answered...

Any help will be greatly appreciated, the main thing I'm trying to achieve here is, with my harvest script, is there a way to use a current gameobject as a guide for the location for the Instantiating Objects?

Youtube Video Here

So when i harvest the plant, I'd wish for the 2 seeds and a block, spawn right where the plant was before harvested. Yes..... i did attempt to research this, yet none of the provided information that works for me, or the Instantiated objects do not spawn where they need to be spawned

instanciate-object.png (106.6 kB)
Comment
Add comment
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

2 Replies

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

Answer by Cherno · Mar 15, 2017 at 11:21 PM

 public int seedAmount = 2;
 public GameObject seedPrefab;
 public GameObject marBlockPrefab;
 public Transform harvestBlock_tr;
 public Transform parentObject_tr;
 
 public void Harvest() {
    for(int i = 0; i < seedAmount; i++) {
      GameObject seed_go = Instantiate(seedPrefab, harvestBlock_tr.position, Quaternion.identity) as GameObject;
         seed_go.transform.SetParent(parentObject_tr);
 }
  GameObject marBlock_go = Instantiate(marBlockPrefab, harvestBlock_tr.position, Quaternion.identity) as GameObject;
         marBlock_go.transform.SetParent(parentObject_tr);
 

 }
 
 
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
avatar image
1

Answer by ifdef_ben · Mar 15, 2017 at 11:19 PM

You can specify the location of the instantiated object in the Instanciate() function. Like this,

 Instanciate(_yourSeedPrefab, new Vector3(114, 80, 373), Quaternion.identity);
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

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

86 People are following this question.

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

Related Questions

Is gameObject present at coordinates (x,y,z)? 1 Answer

Relocate GameObject when location is triggered 0 Answers

How to decide an object's position when using Instantiate? 1 Answer

Load a Scene and Move the Player to an Specific Location. 6 Answers

How do i move a GameObject to the same height as another GameObject? 0 Answers


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