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 amr nasr · Oct 22, 2010 at 06:51 PM · instantiateobjectanother

instatiating an object from another object and automatically tagging it to be collected

Hi all,

what i need is to make an object (3d model) like a machine in a factory instantiate another object (3dmodel) like a product and of course to collect it like the famous item collection game , it has to be tagged.

Does anyone know how to do that?

Perhaps a script will be helpful...................

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by amr nasr · Oct 22, 2010 at 09:39 PM

Okay here is what i found after some research for the timer to be added so that the machine will produce a chocolate every 10 seconds

var myTimer : float=10.0; var chocolate:Transform;

function update () {

if(myTimer>0){ myTimer-=Time.deltaTime;

}

if(myTimer<=0) {

var instatiated = Instantiate(chocolate, transform.Find("Machine").transform.position, Quaternion.identity);

insantiated.tag = chocolate;

    ////////////////////////////////////////////////////
////Shall i add here  ------------myTimer=10.0; again
///////////////////////////////////////////////////

}

}

I would really appreciate if someone answers me

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 kyle · Oct 22, 2010 at 06:57 PM

I believe you need to do this: code//

var WhatEverYouWantHere : Transform;

function update () { //call what you want to happen to cause the instantiate if(whatever) { var instatiated = Instantiate(WhatEverYouWantHere, transform.Find("the thing you want it made at").transform.position, Quaternion.identity); insantiated.tag = collectable; } }

that should probably do it...I hope.

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 amr nasr · Oct 22, 2010 at 08:15 PM 0
Share

Thanks very much for the reply So shall i attach the script to an empty object and that one will find the first object that will instantiate the other object. another thing that i want is to make it do that every 10 second for example to do that

so according to my understanding because i am not a geek yet in unity game engine

the script will look like this


var chocolate:Transform;

function update() {

if(whatever){

var instantiated=instantiate(chocolate.transform.Find("$$anonymous$$achine").transform.position, Quaternion.identity);

insta

avatar image amr nasr · Oct 22, 2010 at 08:16 PM 0
Share

instantiated.tag=chocolate;}

}


Not object#1 prefab is which is the one instantiating the other object is called $$anonymous$$achine, object #2 is called chocolate--------------------

Is what i did correct.......................

and How to modify the code to do that every 10 seconds


i would really appreciate if you answer me regarding that


avatar image kyle · Oct 23, 2010 at 01:55 PM 0
Share

no it's not (chocolate.Transform.Find("$$anonymous$$achine").transform.position, Quaternion.identity);

it's (chocolate, transform.Find("$$anonymous$$achine").transform.position, Quaternion.identity);

avatar image
0

Answer by kyle · Oct 23, 2010 at 01:46 PM

I'm pretty sure that you don't have to add the timer there again since you already called the function and everything good job doing some research on your own and not sitting around and waiting for the answer which some people do, do.

EDIT:

actually looking at your comment again yes you do or else it's going to keep subtracting and not stop, oh and also, ten seconds seems a little long to wait for an Instantiate.

K.N.

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

No one has followed this question yet.

Related Questions

Spawn many object 1 Answer

Random array issue C# 2 Answers

Destroy and instantiate far objects 2 Answers

[Closed]Instantiate object to spesific location 1 Answer

How can i randomly create an array of objects without colliding one another? 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