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 /
This question was closed Dec 04, 2014 at 05:21 AM by Prasanna for the following reason:

Can't get best answer.

avatar image
0
Question by Prasanna · Oct 15, 2014 at 05:52 AM · instantiateobjectrandomhidden

Objects Instantiate

Hello there, am creating a game like a hidden objects. So i have many objects in a room, now i want to create objects in random. Which way is better to get this?

-Prasanna

Comment
Add comment · Show 4
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 Andres-Fernandez · Oct 15, 2014 at 06:25 AM 0
Share

Please, make your question more specific so someone can help. What do you want to randomize? The position? The object to spawn?

Besides, asking for the "better way" opens an often subjective discussion, and UA is not the place for that (that's what the forums are for).

And it is also better if you post your approach to solve the problem. That way you show you are doing some work ins$$anonymous$$d of asking others to do the work for you.

avatar image Redeemer86 · Oct 15, 2014 at 06:33 AM 0
Share

Use a random function to generate vector3 reference locations within required x,y,z coordinates. Then instantiate within required conditions in update if applicable the object/s you wish to spawn. It all really depends on your requirements but this is the basic idea...

Red.

avatar image Prasanna · Oct 15, 2014 at 09:29 AM 0
Share

@Andres Fernandez,. I have a room, in that i need to find the hidden objects, for that i need to create the objects position as random. So the objects are spawn different positions every time.

avatar image Prasanna · Oct 15, 2014 at 09:30 AM 0
Share

@Redeemer86 thanks, i will try.

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by peginet · Oct 15, 2014 at 06:44 AM

Try this script : First you need create empty object and add this script.

 var object1 : Transform;
 var spawner : Transform;
 
 function Update()
 {
 var position : Vector3 = Vector3(Random.Range(-10.0, 10.0), 0, Random.Range(-10.0, 10.0));
 Instantiate(object1, spawner.transform.position + Vector3(0,20,0) + position, 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

Follow this Question

Answers Answers and Comments

32 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

Related Questions

One of the numbers as Second ? 1 Answer

Instantiate object in random position inside a navmesh 1 Answer

Spawning different random objects at the same position? 2 Answers

Random array issue C# 2 Answers

Calling 2 specific random float numbers in random.range using array not working! 2 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