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
0
Question by Jason Hamilton · Jun 21, 2010 at 07:18 AM · instantiateprefab

Instantiate Problem

Whenever I instantiate the Prefab, it doesn't spawn at the position of the sphere but at (0,0,0). why is this? in my script I used "...GameObject.Find("Spawner").transform.position..."

function CreatePlane()
{
    switch(random)
    {
        case 5:
            Instantiate( planePrefab, GameObject.Find("Spawner5").transform.position, Quaternion.identity);
        break;
        case 4:
            Instantiate( planePrefab, GameObject.Find("Spawner4").transform.position, Quaternion.identity);
        break;
        case 3:
            Instantiate( planePrefab, GameObject.Find("Spawner3").transform.position, Quaternion.identity);
        break;
        case 2:
            Instantiate( planePrefab, GameObject.Find("Spawner2").transform.position, Quaternion.identity);
        break;
        case 1:
            Instantiate( planePrefab, GameObject.Find("Spawner1").transform.position, Quaternion.identity);
        break;
    }
}
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 Tetrad · Jun 21, 2010 at 07:20 AM 0
Share

Without seeing more code it's going to be hard to help you.

4 Replies

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

Answer by Mike 3 · Jun 21, 2010 at 08:19 AM

Make sure your script can actually find the Spawner objects first. print out whether or not the return from Find is an actual object.

Next, check the position of that object (via another print) - it's possible that you could have duplicates at Vector3.zero that you didn't know about

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
0

Answer by Jason Hamilton · Jun 21, 2010 at 08:03 AM

Edit: removed the script from here and put it into the question

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
0

Answer by Thomas Hentschel Lund · Jun 21, 2010 at 10:05 AM

That is also my guess. Your code GameObject.Find("Spawner1") doesnt return a valid game object and thus the Instantiate falls back to spawning your object at 0,0,0

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 Cyclops · Jun 21, 2010 at 02:20 PM 0
Share

@$$anonymous$$, no offense, but your reply is basically the same as @$$anonymous$$ike's (as your first line says). It doesn't really warrant a new Answer - if you had any $$anonymous$$or updates, it should go as a comment to another Answer.

avatar image Thomas Hentschel Lund · Jun 24, 2010 at 11:25 AM 0
Share

Ah - none taken. Need to getting used to answering more stuff here "the right way"

avatar image
0

Answer by Tryggvienator · Mar 23, 2012 at 03:35 PM

Is it possible that the item you are instantiating has animation attached to it. If so, try turning the animation off.

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

1 Person is following this question.

avatar image

Related Questions

Scripts of instantiated objects 1 Answer

How to have unique instances of script on multiple instances of prefab? 1 Answer

making prefabs at runtime? 2 Answers

Instantiate A Prefab 1 Answer

Access prefab's variables after instantiation 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