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 /
avatar image
0
Question by PuddingSong · Mar 19, 2013 at 10:31 AM · javascriptspawntagspawning

How do i make an object spawn another one?

I want to be able to make an object i have spawn a copy of another one i have. I think i have to "tag" my objects so when i code they know what im referring to? how do i do this, when i go to change my tags the generic ones come up, i cant add my own, and the script still doesn't know what im talking about. Any help would be appreciated.

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

1 Reply

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

Answer by robertbu · Mar 19, 2013 at 05:09 PM

For tagging, use the Tag Manager. Click on the triangle next to Tags, Increase the size, and An on the right opposite Element#, type in your tag. Then you can use the tag dropdown to set the tag for a specific object.

But to do what I think you want to do, you don't need the tag. Just use the name. Something like:

 var go = GameObject.Find("ObjectName");
 if (go != null)
   Instantiate(go);

Note the object name has to be exactly how you name your object.

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 PuddingSong · Mar 20, 2013 at 07:13 AM 0
Share

Thanks! I got the tagging down, but the actual spawning is still hard. I want to try to make a car model i have spawn an insect model and then after that make the insects change the player. The javascript i made after tagging my insect works (it lets me run the game) but im not sure if im doing it right, i have.

var enemy : GameObject; function start(){ while(true){ Instantiate(enemy,transform.position,transform.rotation); yield WaitForSeconds(1.5); } }

avatar image robertbu · Mar 20, 2013 at 07:43 AM 0
Share

There are a couple of problems with your script. First "Start" function must start with a capital letter. Next, you never return from Start(). Here is an alternative:

 #pragma strict
 
 var enemy : GameObject;
 
 function Start()
 { 
     InvokeRepeating("Spawn", 0.0, 1.5);
 }
 
 function Spawn()
 {
     Instantiate(enemy,transform.position,transform.rotation); 
 }
avatar image PuddingSong · Mar 20, 2013 at 08:18 AM 0
Share

Thanks heaps. I'm really new to this and my internet is really bad, so i cant look up video tutorials. I cant find a site of good text ones either.

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

10 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

Related Questions

character moving after moving 0 Answers

find and destroy Multpile GameObject[] tag. 2 Answers

How to use tag for all players in the Instantiate. 0 Answers

How would I create a script that spawns objects more frequently as time goes on? 3 Answers

2D Player Spawn Issue 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